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

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

Issue 2654733004: [tests] Make assertOptimized()/assertUnoptimized() great again. (Closed)
Patch Set: Rebasing for relanding Created 3 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 unified diff | Download patch
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"
11 #include "src/arguments.h" 11 #include "src/arguments.h"
12 #include "src/base/platform/platform.h" 12 #include "src/base/platform/platform.h"
13 #include "src/compilation-cache.h" 13 #include "src/compilation-cache.h"
14 #include "src/execution.h" 14 #include "src/execution.h"
15 #include "src/objects.h" 15 #include "src/objects.h"
16 #include "src/runtime/runtime.h"
16 #include "src/unicode-inl.h" 17 #include "src/unicode-inl.h"
17 #include "src/utils.h" 18 #include "src/utils.h"
18 19
19 using ::v8::Boolean; 20 using ::v8::Boolean;
20 using ::v8::BooleanObject; 21 using ::v8::BooleanObject;
21 using ::v8::Context; 22 using ::v8::Context;
22 using ::v8::Extension; 23 using ::v8::Extension;
23 using ::v8::Function; 24 using ::v8::Function;
24 using ::v8::FunctionTemplate; 25 using ::v8::FunctionTemplate;
25 using ::v8::HandleScope; 26 using ::v8::HandleScope;
(...skipping 4060 matching lines...) Expand 10 before | Expand all | Expand 10 after
4086 .ToLocalChecked() 4087 .ToLocalChecked()
4087 ->NewInstance(env.local()) 4088 ->NewInstance(env.local())
4088 .ToLocalChecked()) 4089 .ToLocalChecked())
4089 .FromJust(); 4090 .FromJust();
4090 ExpectTrue("obj.x === 42"); 4091 ExpectTrue("obj.x === 42");
4091 ExpectTrue("!obj.propertyIsEnumerable('x')"); 4092 ExpectTrue("!obj.propertyIsEnumerable('x')");
4092 } 4093 }
4093 4094
4094 4095
4095 THREADED_TEST(Regress256330) { 4096 THREADED_TEST(Regress256330) {
4097 if (!i::FLAG_crankshaft) return;
4096 i::FLAG_allow_natives_syntax = true; 4098 i::FLAG_allow_natives_syntax = true;
4097 LocalContext context; 4099 LocalContext context;
4098 v8::HandleScope scope(context->GetIsolate()); 4100 v8::HandleScope scope(context->GetIsolate());
4099 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate()); 4101 Local<FunctionTemplate> templ = FunctionTemplate::New(context->GetIsolate());
4100 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); 4102 AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
4101 context->Global() 4103 context->Global()
4102 ->Set(context.local(), v8_str("Bug"), 4104 ->Set(context.local(), v8_str("Bug"),
4103 templ->GetFunction(context.local()).ToLocalChecked()) 4105 templ->GetFunction(context.local()).ToLocalChecked())
4104 .FromJust(); 4106 .FromJust();
4105 CompileRun( 4107 CompileRun(
4106 "\"use strict\"; var o = new Bug;" 4108 "\"use strict\"; var o = new Bug;"
4107 "function f(o) { o.x = 10; };" 4109 "function f(o) { o.x = 10; };"
4108 "f(o); f(o); f(o);" 4110 "f(o); f(o); f(o);"
4109 "%OptimizeFunctionOnNextCall(f);" 4111 "%OptimizeFunctionOnNextCall(f);"
4110 "f(o);"); 4112 "f(o);");
4111 ExpectBoolean("%GetOptimizationStatus(f) != 2", true); 4113 int status = v8_run_int32value(v8_compile("%GetOptimizationStatus(f)"));
4114 int mask = static_cast<int>(i::OptimizationStatus::kIsFunction) |
4115 static_cast<int>(i::OptimizationStatus::kOptimized);
4116 CHECK_EQ(mask, status & mask);
4112 } 4117 }
4113 4118
4114 4119
4115 THREADED_TEST(CrankshaftInterceptorSetter) { 4120 THREADED_TEST(CrankshaftInterceptorSetter) {
4116 i::FLAG_allow_natives_syntax = true; 4121 i::FLAG_allow_natives_syntax = true;
4117 v8::HandleScope scope(CcTest::isolate()); 4122 v8::HandleScope scope(CcTest::isolate());
4118 Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); 4123 Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate());
4119 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); 4124 AddInterceptor(templ, InterceptorGetter, InterceptorSetter);
4120 LocalContext env; 4125 LocalContext env;
4121 env->Global() 4126 env->Global()
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
4912 ->Set(env.local(), v8_str("Fun"), 4917 ->Set(env.local(), v8_str("Fun"),
4913 fun_templ->GetFunction(env.local()).ToLocalChecked()) 4918 fun_templ->GetFunction(env.local()).ToLocalChecked())
4914 .FromJust()); 4919 .FromJust());
4915 4920
4916 CompileRun( 4921 CompileRun(
4917 "var f = new Fun();" 4922 "var f = new Fun();"
4918 "Number.prototype.__proto__ = f;" 4923 "Number.prototype.__proto__ = f;"
4919 "var a = 42;" 4924 "var a = 42;"
4920 "for (var i = 0; i<3; i++) { a.foo; }"); 4925 "for (var i = 0; i<3; i++) { a.foo; }");
4921 } 4926 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698