OLD | NEW |
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 4061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { |
4096 i::FLAG_allow_natives_syntax = true; | 4097 i::FLAG_allow_natives_syntax = true; |
| 4098 i::FLAG_crankshaft = 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::kIsOptmimizedFunctionMask); |
| 4115 CHECK_EQ(mask, status & mask); |
4112 } | 4116 } |
4113 | 4117 |
4114 | 4118 |
4115 THREADED_TEST(CrankshaftInterceptorSetter) { | 4119 THREADED_TEST(CrankshaftInterceptorSetter) { |
4116 i::FLAG_allow_natives_syntax = true; | 4120 i::FLAG_allow_natives_syntax = true; |
4117 v8::HandleScope scope(CcTest::isolate()); | 4121 v8::HandleScope scope(CcTest::isolate()); |
4118 Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); | 4122 Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); |
4119 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); | 4123 AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
4120 LocalContext env; | 4124 LocalContext env; |
4121 env->Global() | 4125 env->Global() |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4912 ->Set(env.local(), v8_str("Fun"), | 4916 ->Set(env.local(), v8_str("Fun"), |
4913 fun_templ->GetFunction(env.local()).ToLocalChecked()) | 4917 fun_templ->GetFunction(env.local()).ToLocalChecked()) |
4914 .FromJust()); | 4918 .FromJust()); |
4915 | 4919 |
4916 CompileRun( | 4920 CompileRun( |
4917 "var f = new Fun();" | 4921 "var f = new Fun();" |
4918 "Number.prototype.__proto__ = f;" | 4922 "Number.prototype.__proto__ = f;" |
4919 "var a = 42;" | 4923 "var a = 42;" |
4920 "for (var i = 0; i<3; i++) { a.foo; }"); | 4924 "for (var i = 0; i<3; i++) { a.foo; }"); |
4921 } | 4925 } |
OLD | NEW |