Skip to content

Commit fa13da2

Browse files
bmeurerCommit bot
authored andcommitted
[stubs] Fix TypeOfStub to properly return "undefined" for undetectable.
The TypeOfStub didn't test the undetectable bit properly if the instance was also callable, and therefore returned "object" for document.all (which is both undetectable and callable). CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_chromium_rel_ng;tryserver.blink:linux_blink_rel [email protected] BUG=chromium:567998 LOG=n Committed: https://crrev.com/02cc310370df7e51ac4f705038820066fdfd0cdc Cr-Commit-Position: refs/heads/master@{#32852} Review URL: https://codereview.chromium.org/1527863003 Cr-Commit-Position: refs/heads/master@{#32883}
1 parent b742026 commit fa13da2

2 files changed

Lines changed: 49 additions & 2 deletions

File tree

src/code-stubs-hydrogen.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ HValue* CodeStubGraphBuilder<TypeofStub>::BuildCodeStub() {
396396
// Is it an undetectable object?
397397
IfBuilder is_undetectable(this);
398398
is_undetectable.If<HCompareNumericAndBranch>(
399-
bit_field_masked, Add<HConstant>(1 << Map::kIsUndetectable),
400-
Token::EQ);
399+
bit_field_masked, graph()->GetConstant0(), Token::NE);
401400
is_undetectable.Then();
402401
{
403402
// typeof an undetectable object is 'undefined'.

test/cctest/test-api.cc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11654,6 +11654,54 @@ THREADED_TEST(CallableObject) {
1165411654
}
1165511655

1165611656

11657+
THREADED_TEST(Regress567998) {
11658+
LocalContext env;
11659+
v8::HandleScope scope(env->GetIsolate());
11660+
11661+
Local<v8::FunctionTemplate> desc =
11662+
v8::FunctionTemplate::New(env->GetIsolate());
11663+
desc->InstanceTemplate()->MarkAsUndetectable(); // undetectable
11664+
desc->InstanceTemplate()->SetCallAsFunctionHandler(ReturnThis); // callable
11665+
11666+
Local<v8::Object> obj = desc->GetFunction(env.local())
11667+
.ToLocalChecked()
11668+
->NewInstance(env.local())
11669+
.ToLocalChecked();
11670+
CHECK(
11671+
env->Global()->Set(env.local(), v8_str("undetectable"), obj).FromJust());
11672+
11673+
ExpectString("undetectable.toString()", "[object Object]");
11674+
ExpectString("typeof undetectable", "undefined");
11675+
ExpectString("typeof(undetectable)", "undefined");
11676+
ExpectBoolean("typeof undetectable == 'undefined'", true);
11677+
ExpectBoolean("typeof undetectable == 'object'", false);
11678+
ExpectBoolean("if (undetectable) { true; } else { false; }", false);
11679+
ExpectBoolean("!undetectable", true);
11680+
11681+
ExpectObject("true&&undetectable", obj);
11682+
ExpectBoolean("false&&undetectable", false);
11683+
ExpectBoolean("true||undetectable", true);
11684+
ExpectObject("false||undetectable", obj);
11685+
11686+
ExpectObject("undetectable&&true", obj);
11687+
ExpectObject("undetectable&&false", obj);
11688+
ExpectBoolean("undetectable||true", true);
11689+
ExpectBoolean("undetectable||false", false);
11690+
11691+
ExpectBoolean("undetectable==null", true);
11692+
ExpectBoolean("null==undetectable", true);
11693+
ExpectBoolean("undetectable==undefined", true);
11694+
ExpectBoolean("undefined==undetectable", true);
11695+
ExpectBoolean("undetectable==undetectable", true);
11696+
11697+
ExpectBoolean("undetectable===null", false);
11698+
ExpectBoolean("null===undetectable", false);
11699+
ExpectBoolean("undetectable===undefined", false);
11700+
ExpectBoolean("undefined===undetectable", false);
11701+
ExpectBoolean("undetectable===undetectable", true);
11702+
}
11703+
11704+
1165711705
static int Recurse(v8::Isolate* isolate, int depth, int iterations) {
1165811706
v8::HandleScope scope(isolate);
1165911707
if (depth == 0) return v8::HandleScope::NumberOfHandles(isolate);

0 commit comments

Comments
 (0)