Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Version 4.8.271.11 (cherry-pick)
Browse files Browse the repository at this point in the history
Merged fa13da2

[stubs] Fix TypeOfStub to properly return "undefined" for undetectable.

BUG=chromium:567998
LOG=N
[email protected]

Review URL: https://codereview.chromium.org/1546903002 .

Cr-Commit-Position: refs/branch-heads/4.8@{#14}
Cr-Branched-From: 10449d4-refs/heads/4.8.271@{#1}
Cr-Branched-From: 2ebd5fc-refs/heads/master@{#31941}
  • Loading branch information
natorion committed Dec 23, 2015
1 parent ef42af2 commit efc5cbb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 4
#define V8_MINOR_VERSION 8
#define V8_BUILD_NUMBER 271
#define V8_PATCH_LEVEL 10
#define V8_PATCH_LEVEL 11

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
3 changes: 1 addition & 2 deletions src/code-stubs-hydrogen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ HValue* CodeStubGraphBuilder<TypeofStub>::BuildCodeStub() {
// Is it an undetectable object?
IfBuilder is_undetectable(this);
is_undetectable.If<HCompareNumericAndBranch>(
bit_field_masked, Add<HConstant>(1 << Map::kIsUndetectable),
Token::EQ);
bit_field_masked, graph()->GetConstant0(), Token::NE);
is_undetectable.Then();
{
// typeof an undetectable object is 'undefined'.
Expand Down
48 changes: 48 additions & 0 deletions test/cctest/test-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10382,6 +10382,54 @@ THREADED_TEST(CallableObject) {
}


THREADED_TEST(Regress567998) {
LocalContext env;
v8::HandleScope scope(env->GetIsolate());

Local<v8::FunctionTemplate> desc =
v8::FunctionTemplate::New(env->GetIsolate());
desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
desc->InstanceTemplate()->SetCallAsFunctionHandler(ReturnThis); // callable

Local<v8::Object> obj = desc->GetFunction(env.local())
.ToLocalChecked()
->NewInstance(env.local())
.ToLocalChecked();
CHECK(
env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust());

ExpectString("undetectable.toString()", "[object Object]");
ExpectString("typeof undetectable", "undefined");
ExpectString("typeof(undetectable)", "undefined");
ExpectBoolean("typeof undetectable == 'undefined'", true);
ExpectBoolean("typeof undetectable == 'object'", false);
ExpectBoolean("if (undetectable) { true; } else { false; }", false);
ExpectBoolean("!undetectable", true);

ExpectObject("true&&undetectable", obj);
ExpectBoolean("false&&undetectable", false);
ExpectBoolean("true||undetectable", true);
ExpectObject("false||undetectable", obj);

ExpectObject("undetectable&&true", obj);
ExpectObject("undetectable&&false", obj);
ExpectBoolean("undetectable||true", true);
ExpectBoolean("undetectable||false", false);

ExpectBoolean("undetectable==null", true);
ExpectBoolean("null==undetectable", true);
ExpectBoolean("undetectable==undefined", true);
ExpectBoolean("undefined==undetectable", true);
ExpectBoolean("undetectable==undetectable", true);

ExpectBoolean("undetectable===null", false);
ExpectBoolean("null===undetectable", false);
ExpectBoolean("undetectable===undefined", false);
ExpectBoolean("undefined===undetectable", false);
ExpectBoolean("undetectable===undetectable", true);
}


static int Recurse(v8::Isolate* isolate, int depth, int iterations) {
v8::HandleScope scope(isolate);
if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate);
Expand Down

0 comments on commit efc5cbb

Please sign in to comment.