[turbofan] Fix optimization of global loads and stores
They didn't take the new premonomorphic state into account. My bad. Bug: chromium:931424 Change-Id: I74ad1f0f8ce0eb764d63c2a3527e597962baca6d Reviewed-on: https://chromium-review.googlesource.com/c/1470125 Reviewed-by: Michael Stanton <mvstanton@chromium.org> Commit-Queue: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/master@{#59552}
This commit is contained in:
parent
c142e0a2b1
commit
87c985f50a
@ -1009,7 +1009,9 @@ Reduction JSNativeContextSpecialization::ReduceJSLoadGlobal(Node* node) {
|
||||
|
||||
DCHECK(nexus.kind() == FeedbackSlotKind::kLoadGlobalInsideTypeof ||
|
||||
nexus.kind() == FeedbackSlotKind::kLoadGlobalNotInsideTypeof);
|
||||
if (nexus.GetFeedback()->IsCleared()) return NoChange();
|
||||
if (nexus.ic_state() != MONOMORPHIC || nexus.GetFeedback()->IsCleared()) {
|
||||
return NoChange();
|
||||
}
|
||||
Handle<Object> feedback(nexus.GetFeedback()->GetHeapObjectOrSmi(), isolate());
|
||||
|
||||
if (feedback->IsSmi()) {
|
||||
@ -1058,7 +1060,9 @@ Reduction JSNativeContextSpecialization::ReduceJSStoreGlobal(Node* node) {
|
||||
|
||||
DCHECK(nexus.kind() == FeedbackSlotKind::kStoreGlobalSloppy ||
|
||||
nexus.kind() == FeedbackSlotKind::kStoreGlobalStrict);
|
||||
if (nexus.GetFeedback()->IsCleared()) return NoChange();
|
||||
if (nexus.ic_state() != MONOMORPHIC || nexus.GetFeedback()->IsCleared()) {
|
||||
return NoChange();
|
||||
}
|
||||
Handle<Object> feedback(nexus.GetFeedback()->GetHeapObjectOrSmi(), isolate());
|
||||
|
||||
if (feedback->IsSmi()) {
|
||||
|
@ -11058,6 +11058,50 @@ THREADED_TEST(ShadowObjectAndDataProperty) {
|
||||
CHECK(heap_object->IsPropertyCell());
|
||||
}
|
||||
|
||||
THREADED_TEST(ShadowObjectAndDataPropertyTurbo) {
|
||||
// This test is the same as the previous one except that it triggers
|
||||
// optimization of {foo} after its first invocation.
|
||||
i::FLAG_allow_natives_syntax = true;
|
||||
|
||||
if (i::FLAG_lite_mode) return;
|
||||
v8::Isolate* isolate = CcTest::isolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
Local<ObjectTemplate> global_template = v8::ObjectTemplate::New(isolate);
|
||||
LocalContext context(nullptr, global_template);
|
||||
|
||||
Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate);
|
||||
t->InstanceTemplate()->SetHandler(
|
||||
v8::NamedPropertyHandlerConfiguration(ShadowNamedGet));
|
||||
|
||||
Local<Value> o = t->GetFunction(context.local())
|
||||
.ToLocalChecked()
|
||||
->NewInstance(context.local())
|
||||
.ToLocalChecked();
|
||||
CHECK(context->Global()
|
||||
->Set(context.local(), v8_str("__proto__"), o)
|
||||
.FromJust());
|
||||
|
||||
CompileRun(
|
||||
"function foo(x) { i = x; }"
|
||||
"foo(0)");
|
||||
|
||||
i::Handle<i::JSFunction> foo(i::Handle<i::JSFunction>::cast(
|
||||
v8::Utils::OpenHandle(*context->Global()
|
||||
->Get(context.local(), v8_str("foo"))
|
||||
.ToLocalChecked())));
|
||||
CHECK(foo->has_feedback_vector());
|
||||
i::FeedbackSlot slot = i::FeedbackVector::ToSlot(0);
|
||||
i::FeedbackNexus nexus(foo->feedback_vector(), slot);
|
||||
CHECK_EQ(i::FeedbackSlotKind::kStoreGlobalSloppy, nexus.kind());
|
||||
CHECK_EQ(i::PREMONOMORPHIC, nexus.StateFromFeedback());
|
||||
CompileRun("%OptimizeFunctionOnNextCall(foo); foo(1)");
|
||||
CHECK_EQ(i::MONOMORPHIC, nexus.StateFromFeedback());
|
||||
i::HeapObject heap_object;
|
||||
CHECK(nexus.GetFeedback().GetHeapObject(&heap_object));
|
||||
CHECK(heap_object->IsPropertyCell());
|
||||
}
|
||||
|
||||
THREADED_TEST(SetPrototype) {
|
||||
LocalContext context;
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
|
Loading…
Reference in New Issue
Block a user