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

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

Issue 1215593005: Update tests to disable interceptors during bootstrapping (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "test/cctest/test-api.h" 7 #include "test/cctest/test-api.h"
8 8
9 #include "include/v8-util.h" 9 #include "include/v8-util.h"
10 #include "src/api.h" 10 #include "src/api.h"
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 1000
1001 // Indexed and named deleter. 1001 // Indexed and named deleter.
1002 CompileRun("delete obj[0]"); 1002 CompileRun("delete obj[0]");
1003 CompileRun("delete obj.x"); 1003 CompileRun("delete obj.x");
1004 1004
1005 // Enumerators. 1005 // Enumerators.
1006 CompileRun("for (var p in obj) ;"); 1006 CompileRun("for (var p in obj) ;");
1007 } 1007 }
1008 1008
1009 1009
1010 bool is_bootstrapping = true;
1010 static void PrePropertyHandlerGet( 1011 static void PrePropertyHandlerGet(
1011 Local<Name> key, const v8::PropertyCallbackInfo<v8::Value>& info) { 1012 Local<Name> key, const v8::PropertyCallbackInfo<v8::Value>& info) {
1012 ApiTestFuzzer::Fuzz(); 1013 ApiTestFuzzer::Fuzz();
1013 if (v8_str("pre")->Equals(key)) { 1014 if (!is_bootstrapping && v8_str("pre")->Equals(key)) {
1014 info.GetReturnValue().Set(v8_str("PrePropertyHandler: pre")); 1015 info.GetReturnValue().Set(v8_str("PrePropertyHandler: pre"));
1015 } 1016 }
1016 } 1017 }
1017 1018
1018 1019
1019 static void PrePropertyHandlerQuery( 1020 static void PrePropertyHandlerQuery(
1020 Local<Name> key, const v8::PropertyCallbackInfo<v8::Integer>& info) { 1021 Local<Name> key, const v8::PropertyCallbackInfo<v8::Integer>& info) {
1021 if (v8_str("pre")->Equals(key)) { 1022 if (!is_bootstrapping && v8_str("pre")->Equals(key)) {
1022 info.GetReturnValue().Set(static_cast<int32_t>(v8::None)); 1023 info.GetReturnValue().Set(static_cast<int32_t>(v8::None));
1023 } 1024 }
1024 } 1025 }
1025 1026
1026 1027
1027 THREADED_TEST(PrePropertyHandler) { 1028 THREADED_TEST(PrePropertyHandler) {
1028 v8::Isolate* isolate = CcTest::isolate(); 1029 v8::Isolate* isolate = CcTest::isolate();
1029 v8::HandleScope scope(isolate); 1030 v8::HandleScope scope(isolate);
1030 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate); 1031 v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(isolate);
1031 desc->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration( 1032 desc->InstanceTemplate()->SetHandler(v8::NamedPropertyHandlerConfiguration(
1032 PrePropertyHandlerGet, 0, PrePropertyHandlerQuery)); 1033 PrePropertyHandlerGet, 0, PrePropertyHandlerQuery));
1034 is_bootstrapping = true;
1033 LocalContext env(NULL, desc->InstanceTemplate()); 1035 LocalContext env(NULL, desc->InstanceTemplate());
1036 is_bootstrapping = false;
1034 CompileRun("var pre = 'Object: pre'; var on = 'Object: on';"); 1037 CompileRun("var pre = 'Object: pre'; var on = 'Object: on';");
1035 v8::Handle<Value> result_pre = CompileRun("pre"); 1038 v8::Handle<Value> result_pre = CompileRun("pre");
1036 CHECK(v8_str("PrePropertyHandler: pre")->Equals(result_pre)); 1039 CHECK(v8_str("PrePropertyHandler: pre")->Equals(result_pre));
1037 v8::Handle<Value> result_on = CompileRun("on"); 1040 v8::Handle<Value> result_on = CompileRun("on");
1038 CHECK(v8_str("Object: on")->Equals(result_on)); 1041 CHECK(v8_str("Object: on")->Equals(result_on));
1039 v8::Handle<Value> result_post = CompileRun("post"); 1042 v8::Handle<Value> result_post = CompileRun("post");
1040 CHECK(result_post.IsEmpty()); 1043 CHECK(result_post.IsEmpty());
1041 } 1044 }
1042 1045
1043 1046
(...skipping 1497 matching lines...) Expand 10 before | Expand all | Expand 10 after
2541 2544
2542 // This test should hit load and call ICs for the interceptor case. 2545 // This test should hit load and call ICs for the interceptor case.
2543 // Once in a while, the interceptor will reply that a property was not 2546 // Once in a while, the interceptor will reply that a property was not
2544 // found in which case we should get a reference error. 2547 // found in which case we should get a reference error.
2545 THREADED_TEST(InterceptorICReferenceErrors) { 2548 THREADED_TEST(InterceptorICReferenceErrors) {
2546 v8::Isolate* isolate = CcTest::isolate(); 2549 v8::Isolate* isolate = CcTest::isolate();
2547 v8::HandleScope scope(isolate); 2550 v8::HandleScope scope(isolate);
2548 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); 2551 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate);
2549 templ->SetHandler( 2552 templ->SetHandler(
2550 v8::NamedPropertyHandlerConfiguration(InterceptorICRefErrorGetter)); 2553 v8::NamedPropertyHandlerConfiguration(InterceptorICRefErrorGetter));
2554 interceptor_call_count = -100000; // Generous limit for bootstrapping.
2551 LocalContext context(0, templ, v8::Handle<Value>()); 2555 LocalContext context(0, templ, v8::Handle<Value>());
2556 interceptor_call_count = 0;
2552 call_ic_function2 = v8_compile("function h(x) { return x; }; h")->Run(); 2557 call_ic_function2 = v8_compile("function h(x) { return x; }; h")->Run();
2553 v8::Handle<Value> value = CompileRun( 2558 v8::Handle<Value> value = CompileRun(
2554 "function f() {" 2559 "function f() {"
2555 " for (var i = 0; i < 1000; i++) {" 2560 " for (var i = 0; i < 1000; i++) {"
2556 " try { x; } catch(e) { return true; }" 2561 " try { x; } catch(e) { return true; }"
2557 " }" 2562 " }"
2558 " return false;" 2563 " return false;"
2559 "};" 2564 "};"
2560 "f();"); 2565 "f();");
2561 CHECK_EQ(true, value->BooleanValue()); 2566 CHECK_EQ(true, value->BooleanValue());
(...skipping 25 matching lines...) Expand all
2587 } 2592 }
2588 2593
2589 2594
2590 // Test interceptor load/call IC where the interceptor throws an 2595 // Test interceptor load/call IC where the interceptor throws an
2591 // exception once in a while. 2596 // exception once in a while.
2592 THREADED_TEST(InterceptorICGetterExceptions) { 2597 THREADED_TEST(InterceptorICGetterExceptions) {
2593 interceptor_ic_exception_get_count = 0; 2598 interceptor_ic_exception_get_count = 0;
2594 v8::Isolate* isolate = CcTest::isolate(); 2599 v8::Isolate* isolate = CcTest::isolate();
2595 v8::HandleScope scope(isolate); 2600 v8::HandleScope scope(isolate);
2596 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate); 2601 v8::Handle<v8::ObjectTemplate> templ = ObjectTemplate::New(isolate);
2602 // Generous limit for bootstrapping.
2603 interceptor_ic_exception_get_count = -100000;
2597 templ->SetHandler( 2604 templ->SetHandler(
2598 v8::NamedPropertyHandlerConfiguration(InterceptorICExceptionGetter)); 2605 v8::NamedPropertyHandlerConfiguration(InterceptorICExceptionGetter));
2599 LocalContext context(0, templ, v8::Handle<Value>()); 2606 LocalContext context(0, templ, v8::Handle<Value>());
2607 interceptor_ic_exception_get_count = 0;
2600 call_ic_function3 = v8_compile("function h(x) { return x; }; h")->Run(); 2608 call_ic_function3 = v8_compile("function h(x) { return x; }; h")->Run();
2601 v8::Handle<Value> value = CompileRun( 2609 v8::Handle<Value> value = CompileRun(
2602 "function f() {" 2610 "function f() {"
2603 " for (var i = 0; i < 100; i++) {" 2611 " for (var i = 0; i < 100; i++) {"
2604 " try { x; } catch(e) { return true; }" 2612 " try { x; } catch(e) { return true; }"
2605 " }" 2613 " }"
2606 " return false;" 2614 " return false;"
2607 "};" 2615 "};"
2608 "f();"); 2616 "f();");
2609 CHECK_EQ(true, value->BooleanValue()); 2617 CHECK_EQ(true, value->BooleanValue());
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
3306 "var obj = intercepted_1;" 3314 "var obj = intercepted_1;"
3307 "obj.x = 4;" 3315 "obj.x = 4;"
3308 "eval('obj.x');" 3316 "eval('obj.x');"
3309 "eval('obj.x');" 3317 "eval('obj.x');"
3310 "eval('obj.x');" 3318 "eval('obj.x');"
3311 "obj = intercepted_2;" 3319 "obj = intercepted_2;"
3312 "obj.x = 9;" 3320 "obj.x = 9;"
3313 "eval('obj.x');", 3321 "eval('obj.x');",
3314 9); 3322 9);
3315 } 3323 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698