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

Side by Side Diff: test/cctest/test-api.cc

Issue 365153002: Remove a bunch of Isolate::UncheckedCurrent calls (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« include/v8.h ('K') | « src/isolate.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 19477 matching lines...) Expand 10 before | Expand all | Expand 10 after
19488 constraints.set_max_old_space_size(4); 19488 constraints.set_max_old_space_size(4);
19489 v8::SetResourceConstraints(CcTest::isolate(), &constraints); 19489 v8::SetResourceConstraints(CcTest::isolate(), &constraints);
19490 break; 19490 break;
19491 } 19491 }
19492 19492
19493 case SetFatalHandler: 19493 case SetFatalHandler:
19494 v8::V8::SetFatalErrorHandler(NULL); 19494 v8::V8::SetFatalErrorHandler(NULL);
19495 break; 19495 break;
19496 19496
19497 case SetCounterFunction: 19497 case SetCounterFunction:
19498 v8::V8::SetCounterFunction(NULL); 19498 CcTest::isolate()->SetCounterFunction(NULL);
19499 break; 19499 break;
19500 19500
19501 case SetCreateHistogramFunction: 19501 case SetCreateHistogramFunction:
19502 v8::V8::SetCreateHistogramFunction(NULL); 19502 CcTest::isolate()->SetCreateHistogramFunction(NULL);
19503 break; 19503 break;
19504 19504
19505 case SetAddHistogramSampleFunction: 19505 case SetAddHistogramSampleFunction:
19506 v8::V8::SetAddHistogramSampleFunction(NULL); 19506 CcTest::isolate()->SetAddHistogramSampleFunction(NULL);
19507 break; 19507 break;
19508 } 19508 }
19509 isolate->Exit(); 19509 isolate->Exit();
19510 isolate->Dispose(); 19510 isolate->Dispose();
19511 result_ = true; 19511 result_ = true;
19512 } 19512 }
19513 19513
19514 bool result() { return result_; } 19514 bool result() { return result_; }
19515 19515
19516 private: 19516 private:
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
20879 CompileRun("var obj = {};" 20879 CompileRun("var obj = {};"
20880 "Object.observe(obj, function(changes) { debugger; });" 20880 "Object.observe(obj, function(changes) { debugger; });"
20881 "obj.a = 0;"); 20881 "obj.a = 0;");
20882 } 20882 }
20883 isolate->RunMicrotasks(); 20883 isolate->RunMicrotasks();
20884 isolate->SetAutorunMicrotasks(true); 20884 isolate->SetAutorunMicrotasks(true);
20885 v8::Debug::SetDebugEventListener(NULL); 20885 v8::Debug::SetDebugEventListener(NULL);
20886 } 20886 }
20887 20887
20888 20888
20889 #ifdef DEBUG
20889 static int probes_counter = 0; 20890 static int probes_counter = 0;
20890 static int misses_counter = 0; 20891 static int misses_counter = 0;
20891 static int updates_counter = 0; 20892 static int updates_counter = 0;
20892 20893
20893 20894
20894 static int* LookupCounter(const char* name) { 20895 static int* LookupCounter(const char* name) {
20895 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) { 20896 if (strcmp(name, "c:V8.MegamorphicStubCacheProbes") == 0) {
20896 return &probes_counter; 20897 return &probes_counter;
20897 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) { 20898 } else if (strcmp(name, "c:V8.MegamorphicStubCacheMisses") == 0) {
20898 return &misses_counter; 20899 return &misses_counter;
20899 } else if (strcmp(name, "c:V8.MegamorphicStubCacheUpdates") == 0) { 20900 } else if (strcmp(name, "c:V8.MegamorphicStubCacheUpdates") == 0) {
20900 return &updates_counter; 20901 return &updates_counter;
20901 } 20902 }
20902 return NULL; 20903 return NULL;
20903 } 20904 }
20904 20905
20905 20906
20906 static const char* kMegamorphicTestProgram = 20907 static const char* kMegamorphicTestProgram =
20907 "function ClassA() { };" 20908 "function ClassA() { };"
20908 "function ClassB() { };" 20909 "function ClassB() { };"
20909 "ClassA.prototype.foo = function() { };" 20910 "ClassA.prototype.foo = function() { };"
20910 "ClassB.prototype.foo = function() { };" 20911 "ClassB.prototype.foo = function() { };"
20911 "function fooify(obj) { obj.foo(); };" 20912 "function fooify(obj) { obj.foo(); };"
20912 "var a = new ClassA();" 20913 "var a = new ClassA();"
20913 "var b = new ClassB();" 20914 "var b = new ClassB();"
20914 "for (var i = 0; i < 10000; i++) {" 20915 "for (var i = 0; i < 10000; i++) {"
20915 " fooify(a);" 20916 " fooify(a);"
20916 " fooify(b);" 20917 " fooify(b);"
20917 "}"; 20918 "}";
20919 #endif
20918 20920
20919 20921
20920 static void StubCacheHelper(bool primary) { 20922 static void StubCacheHelper(bool primary) {
20921 V8::SetCounterFunction(LookupCounter);
20922 USE(kMegamorphicTestProgram);
20923 #ifdef DEBUG 20923 #ifdef DEBUG
20924 i::FLAG_native_code_counters = true; 20924 i::FLAG_native_code_counters = true;
20925 if (primary) { 20925 if (primary) {
20926 i::FLAG_test_primary_stub_cache = true; 20926 i::FLAG_test_primary_stub_cache = true;
20927 } else { 20927 } else {
20928 i::FLAG_test_secondary_stub_cache = true; 20928 i::FLAG_test_secondary_stub_cache = true;
20929 } 20929 }
20930 i::FLAG_crankshaft = false; 20930 i::FLAG_crankshaft = false;
20931 LocalContext env; 20931 LocalContext env;
20932 env->GetIsolate()->SetCounterFunction(LookupCounter);
20932 v8::HandleScope scope(env->GetIsolate()); 20933 v8::HandleScope scope(env->GetIsolate());
20933 int initial_probes = probes_counter; 20934 int initial_probes = probes_counter;
20934 int initial_misses = misses_counter; 20935 int initial_misses = misses_counter;
20935 int initial_updates = updates_counter; 20936 int initial_updates = updates_counter;
20936 CompileRun(kMegamorphicTestProgram); 20937 CompileRun(kMegamorphicTestProgram);
20937 int probes = probes_counter - initial_probes; 20938 int probes = probes_counter - initial_probes;
20938 int misses = misses_counter - initial_misses; 20939 int misses = misses_counter - initial_misses;
20939 int updates = updates_counter - initial_updates; 20940 int updates = updates_counter - initial_updates;
20940 CHECK_LT(updates, 10); 20941 CHECK_LT(updates, 10);
20941 CHECK_LT(misses, 10); 20942 CHECK_LT(misses, 10);
20942 // TODO(verwaest): Update this test to overflow the degree of polymorphism 20943 // TODO(verwaest): Update this test to overflow the degree of polymorphism
20943 // before megamorphism. The number of probes will only work once we teach the 20944 // before megamorphism. The number of probes will only work once we teach the
20944 // serializer to embed references to counters in the stubs, given that the 20945 // serializer to embed references to counters in the stubs, given that the
20945 // megamorphic_stub_cache_probes is updated in a snapshot-generated stub. 20946 // megamorphic_stub_cache_probes is updated in a snapshot-generated stub.
20946 CHECK_GE(probes, 0); 20947 CHECK_GE(probes, 0);
20947 #endif 20948 #endif
20948 } 20949 }
20949 20950
20950 20951
20951 TEST(SecondaryStubCache) { 20952 TEST(SecondaryStubCache) {
20952 StubCacheHelper(true); 20953 StubCacheHelper(true);
20953 } 20954 }
20954 20955
20955 20956
20956 TEST(PrimaryStubCache) { 20957 TEST(PrimaryStubCache) {
20957 StubCacheHelper(false); 20958 StubCacheHelper(false);
20958 } 20959 }
20959 20960
20960 20961
20962 #ifdef DEBUG
20961 static int cow_arrays_created_runtime = 0; 20963 static int cow_arrays_created_runtime = 0;
20962 20964
20963 20965
20964 static int* LookupCounterCOWArrays(const char* name) { 20966 static int* LookupCounterCOWArrays(const char* name) {
20965 if (strcmp(name, "c:V8.COWArraysCreatedRuntime") == 0) { 20967 if (strcmp(name, "c:V8.COWArraysCreatedRuntime") == 0) {
20966 return &cow_arrays_created_runtime; 20968 return &cow_arrays_created_runtime;
20967 } 20969 }
20968 return NULL; 20970 return NULL;
20969 } 20971 }
20972 #endif
20970 20973
20971 20974
20972 TEST(CheckCOWArraysCreatedRuntimeCounter) { 20975 TEST(CheckCOWArraysCreatedRuntimeCounter) {
20973 V8::SetCounterFunction(LookupCounterCOWArrays);
20974 #ifdef DEBUG 20976 #ifdef DEBUG
20975 i::FLAG_native_code_counters = true; 20977 i::FLAG_native_code_counters = true;
20976 LocalContext env; 20978 LocalContext env;
20979 env->GetIsolate()->SetCounterFunction(LookupCounterCOWArrays);
20977 v8::HandleScope scope(env->GetIsolate()); 20980 v8::HandleScope scope(env->GetIsolate());
20978 int initial_cow_arrays = cow_arrays_created_runtime; 20981 int initial_cow_arrays = cow_arrays_created_runtime;
20979 CompileRun("var o = [1, 2, 3];"); 20982 CompileRun("var o = [1, 2, 3];");
20980 CHECK_EQ(1, cow_arrays_created_runtime - initial_cow_arrays); 20983 CHECK_EQ(1, cow_arrays_created_runtime - initial_cow_arrays);
20981 CompileRun("var o = {foo: [4, 5, 6], bar: [3, 0]};"); 20984 CompileRun("var o = {foo: [4, 5, 6], bar: [3, 0]};");
20982 CHECK_EQ(3, cow_arrays_created_runtime - initial_cow_arrays); 20985 CHECK_EQ(3, cow_arrays_created_runtime - initial_cow_arrays);
20983 CompileRun("var o = {foo: [1, 2, 3, [4, 5, 6]], bar: 'hi'};"); 20986 CompileRun("var o = {foo: [1, 2, 3, [4, 5, 6]], bar: 'hi'};");
20984 CHECK_EQ(4, cow_arrays_created_runtime - initial_cow_arrays); 20987 CHECK_EQ(4, cow_arrays_created_runtime - initial_cow_arrays);
20985 #endif 20988 #endif
20986 } 20989 }
(...skipping 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
22891 desc = x->GetOwnPropertyDescriptor(v8_str("p1")); 22894 desc = x->GetOwnPropertyDescriptor(v8_str("p1"));
22892 Local<Function> set = 22895 Local<Function> set =
22893 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set"))); 22896 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("set")));
22894 Local<Function> get = 22897 Local<Function> get =
22895 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get"))); 22898 Local<Function>::Cast(Local<Object>::Cast(desc)->Get(v8_str("get")));
22896 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL)); 22899 CHECK_EQ(v8_num(13), get->Call(x, 0, NULL));
22897 Handle<Value> args[] = { v8_num(14) }; 22900 Handle<Value> args[] = { v8_num(14) };
22898 set->Call(x, 1, args); 22901 set->Call(x, 1, args);
22899 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL)); 22902 CHECK_EQ(v8_num(14), get->Call(x, 0, NULL));
22900 } 22903 }
OLDNEW
« include/v8.h ('K') | « src/isolate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698