Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(912)

Unified Diff: test/cctest/heap/test-heap.cc

Issue 1668103002: Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/cctest/compiler/test-run-jscalls.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/heap/test-heap.cc
diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc
index 2939c988d529588da72669447f6653919639df26..f5705488bd150a5a432dbd2ccf23af478249ba29 100644
--- a/test/cctest/heap/test-heap.cc
+++ b/test/cctest/heap/test-heap.cc
@@ -1516,6 +1516,9 @@ TEST(TestCodeFlushingIncrementalAbort) {
}
TEST(TestUseOfIncrementalBarrierOnCompileLazy) {
+ // This test requires us to run the CompileLazy builtin, which won't be run
+ // when the interpreter is used.
+ if (i::FLAG_ignition) return;
// Turn off always_opt because it interferes with running the built-in for
// the last call to g().
i::FLAG_always_opt = false;
@@ -1545,10 +1548,7 @@ TEST(TestUseOfIncrementalBarrierOnCompileLazy) {
Handle<Object> g_value =
Object::GetProperty(isolate->global_object(), g_name).ToHandleChecked();
Handle<JSFunction> g_function = Handle<JSFunction>::cast(g_value);
- // TODO(mvstanton): change to check that g is *not* compiled when optimized
- // cache
- // map lookup moves to the compile lazy builtin.
- CHECK(g_function->is_compiled());
+ CHECK(!g_function->is_compiled());
SimulateIncrementalMarking(heap);
CompileRun("%OptimizeFunctionOnNextCall(f); f();");
@@ -3678,7 +3678,7 @@ TEST(IncrementalMarkingPreservesMonomorphicCallIC) {
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
- Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
+ Handle<TypeFeedbackVector> feedback_vector(f->feedback_vector());
FeedbackVectorHelper feedback_helper(feedback_vector);
int expected_slots = 2;
@@ -3715,7 +3715,7 @@ static Code* FindFirstIC(Code* code, Code::Kind kind) {
static void CheckVectorIC(Handle<JSFunction> f, int slot_index,
InlineCacheState desired_state) {
Handle<TypeFeedbackVector> vector =
- Handle<TypeFeedbackVector>(f->shared()->feedback_vector());
+ Handle<TypeFeedbackVector>(f->feedback_vector());
FeedbackVectorHelper helper(vector);
FeedbackVectorSlot slot = helper.slot(slot_index);
if (vector->GetKind(slot) == FeedbackVectorSlotKind::LOAD_IC) {
@@ -3729,15 +3729,6 @@ static void CheckVectorIC(Handle<JSFunction> f, int slot_index,
}
-static void CheckVectorICCleared(Handle<JSFunction> f, int slot_index) {
- Handle<TypeFeedbackVector> vector =
- Handle<TypeFeedbackVector>(f->shared()->feedback_vector());
- FeedbackVectorSlot slot(slot_index);
- LoadICNexus nexus(vector, slot);
- CHECK(IC::IsCleared(&nexus));
-}
-
-
TEST(IncrementalMarkingPreservesMonomorphicConstructor) {
if (i::FLAG_always_opt) return;
CcTest::InitializeVM();
@@ -3752,7 +3743,7 @@ TEST(IncrementalMarkingPreservesMonomorphicConstructor) {
v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
- Handle<TypeFeedbackVector> vector(f->shared()->feedback_vector());
+ Handle<TypeFeedbackVector> vector(f->feedback_vector());
CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell());
SimulateIncrementalMarking(CcTest::heap());
@@ -3762,44 +3753,6 @@ TEST(IncrementalMarkingPreservesMonomorphicConstructor) {
}
-TEST(IncrementalMarkingClearsMonomorphicConstructor) {
- if (i::FLAG_always_opt) return;
- CcTest::InitializeVM();
- Isolate* isolate = CcTest::i_isolate();
- v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> fun1;
- v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
-
- {
- LocalContext env;
- CompileRun("function fun() { this.x = 1; };");
- fun1 = env->Global()->Get(env.local(), v8_str("fun")).ToLocalChecked();
- }
-
- // Prepare function f that contains a monomorphic constructor for object
- // originating from a different native context.
- CHECK(CcTest::global()->Set(ctx, v8_str("fun1"), fun1).FromJust());
- CompileRun(
- "function fun() { this.x = 1; };"
- "function f(o) { return new o(); } f(fun1); f(fun1);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(
- v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
- CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
-
-
- Handle<TypeFeedbackVector> vector(f->shared()->feedback_vector());
- CHECK(vector->Get(FeedbackVectorSlot(0))->IsWeakCell());
-
- // Fire context dispose notification.
- CcTest::isolate()->ContextDisposedNotification();
- SimulateIncrementalMarking(CcTest::heap());
- CcTest::heap()->CollectAllGarbage();
-
- CHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(isolate),
- vector->Get(FeedbackVectorSlot(0)));
-}
-
-
TEST(IncrementalMarkingPreservesMonomorphicIC) {
if (i::FLAG_always_opt) return;
CcTest::InitializeVM();
@@ -3822,38 +3775,6 @@ TEST(IncrementalMarkingPreservesMonomorphicIC) {
}
-TEST(IncrementalMarkingClearsMonomorphicIC) {
- if (i::FLAG_always_opt) return;
- CcTest::InitializeVM();
- v8::HandleScope scope(CcTest::isolate());
- v8::Local<v8::Value> obj1;
- v8::Local<v8::Context> ctx = CcTest::isolate()->GetCurrentContext();
-
- {
- LocalContext env;
- CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
- obj1 = env->Global()->Get(env.local(), v8_str("obj")).ToLocalChecked();
- }
-
- // Prepare function f that contains a monomorphic IC for object
- // originating from a different native context.
- CHECK(CcTest::global()->Set(ctx, v8_str("obj1"), obj1).FromJust());
- CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);");
- Handle<JSFunction> f = Handle<JSFunction>::cast(
- v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast(
- CcTest::global()->Get(ctx, v8_str("f")).ToLocalChecked())));
-
- CheckVectorIC(f, 0, MONOMORPHIC);
-
- // Fire context dispose notification.
- CcTest::isolate()->ContextDisposedNotification();
- SimulateIncrementalMarking(CcTest::heap());
- CcTest::heap()->CollectAllGarbage();
-
- CheckVectorICCleared(f, 0);
-}
-
-
TEST(IncrementalMarkingPreservesPolymorphicIC) {
if (i::FLAG_always_opt) return;
CcTest::InitializeVM();
@@ -3891,8 +3812,7 @@ TEST(IncrementalMarkingPreservesPolymorphicIC) {
CheckVectorIC(f, 0, POLYMORPHIC);
}
-
-TEST(IncrementalMarkingClearsPolymorphicIC) {
+TEST(ContextDisposeDoesntClearPolymorphicIC) {
if (i::FLAG_always_opt) return;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
@@ -3927,7 +3847,7 @@ TEST(IncrementalMarkingClearsPolymorphicIC) {
SimulateIncrementalMarking(CcTest::heap());
CcTest::heap()->CollectAllGarbage();
- CheckVectorICCleared(f, 0);
+ CheckVectorIC(f, 0, POLYMORPHIC);
}
@@ -4343,7 +4263,8 @@ TEST(Regress513507) {
if (!code->is_optimized_code()) return;
}
- Handle<TypeFeedbackVector> vector = handle(shared->feedback_vector());
+ Handle<TypeFeedbackVector> vector =
+ TypeFeedbackVector::New(isolate, handle(shared->feedback_metadata()));
Handle<LiteralsArray> lit =
LiteralsArray::New(isolate, vector, shared->num_literals(), TENURED);
Handle<Context> context(isolate->context());
@@ -4400,7 +4321,8 @@ TEST(Regress514122) {
if (!code->is_optimized_code()) return;
}
- Handle<TypeFeedbackVector> vector = handle(shared->feedback_vector());
+ Handle<TypeFeedbackVector> vector =
+ TypeFeedbackVector::New(isolate, handle(shared->feedback_metadata()));
Handle<LiteralsArray> lit =
LiteralsArray::New(isolate, vector, shared->num_literals(), TENURED);
Handle<Context> context(isolate->context());
@@ -5104,7 +5026,7 @@ TEST(WeakFunctionInConstructor) {
// cleared. Now, verify that one additional call with a new function
// allows monomorphicity.
Handle<TypeFeedbackVector> feedback_vector = Handle<TypeFeedbackVector>(
- createObj->shared()->feedback_vector(), CcTest::i_isolate());
+ createObj->feedback_vector(), CcTest::i_isolate());
for (int i = 0; i < 20; i++) {
Object* slot_value = feedback_vector->Get(FeedbackVectorSlot(0));
CHECK(slot_value->IsWeakCell());
@@ -5305,12 +5227,11 @@ Handle<JSFunction> GetFunctionByName(Isolate* isolate, const char* name) {
return Handle<JSFunction>::cast(obj);
}
-
-void CheckIC(Code* code, Code::Kind kind, SharedFunctionInfo* shared,
- int slot_index, InlineCacheState state) {
+void CheckIC(Handle<JSFunction> function, Code::Kind kind, int slot_index,
+ InlineCacheState state) {
if (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC ||
kind == Code::CALL_IC) {
- TypeFeedbackVector* vector = shared->feedback_vector();
+ TypeFeedbackVector* vector = function->feedback_vector();
FeedbackVectorSlot slot(slot_index);
if (kind == Code::LOAD_IC) {
LoadICNexus nexus(vector, slot);
@@ -5323,7 +5244,7 @@ void CheckIC(Code* code, Code::Kind kind, SharedFunctionInfo* shared,
CHECK_EQ(nexus.StateFromFeedback(), state);
}
} else {
- Code* ic = FindFirstIC(code, kind);
+ Code* ic = FindFirstIC(function->code(), kind);
CHECK(ic->is_inline_cache_stub());
CHECK(ic->ic_state() == state);
}
@@ -5354,12 +5275,12 @@ TEST(MonomorphicStaysMonomorphicAfterGC) {
CompileRun("(testIC())");
}
heap->CollectAllGarbage();
- CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, MONOMORPHIC);
+ CheckIC(loadIC, Code::LOAD_IC, 0, MONOMORPHIC);
{
v8::HandleScope scope(CcTest::isolate());
CompileRun("(testIC())");
}
- CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, MONOMORPHIC);
+ CheckIC(loadIC, Code::LOAD_IC, 0, MONOMORPHIC);
}
@@ -5390,12 +5311,12 @@ TEST(PolymorphicStaysPolymorphicAfterGC) {
CompileRun("(testIC())");
}
heap->CollectAllGarbage();
- CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, POLYMORPHIC);
+ CheckIC(loadIC, Code::LOAD_IC, 0, POLYMORPHIC);
{
v8::HandleScope scope(CcTest::isolate());
CompileRun("(testIC())");
}
- CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, POLYMORPHIC);
+ CheckIC(loadIC, Code::LOAD_IC, 0, POLYMORPHIC);
}
« no previous file with comments | « test/cctest/compiler/test-run-jscalls.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698