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

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

Issue 885763004: follow up named interceptor miss with api callback getter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/ic/handler-compiler.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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 CHECK(signature_expected_receiver->Equals(args.Holder())); 110 CHECK(signature_expected_receiver->Equals(args.Holder()));
111 CHECK(signature_expected_receiver->Equals(args.This())); 111 CHECK(signature_expected_receiver->Equals(args.This()));
112 v8::Handle<v8::Array> result = 112 v8::Handle<v8::Array> result =
113 v8::Array::New(args.GetIsolate(), args.Length()); 113 v8::Array::New(args.GetIsolate(), args.Length());
114 for (int i = 0; i < args.Length(); i++) 114 for (int i = 0; i < args.Length(); i++)
115 result->Set(v8::Integer::New(args.GetIsolate(), i), args[i]); 115 result->Set(v8::Integer::New(args.GetIsolate(), i), args[i]);
116 args.GetReturnValue().Set(result); 116 args.GetReturnValue().Set(result);
117 } 117 }
118 118
119 119
120 static void Returns42(const v8::FunctionCallbackInfo<v8::Value>& info) {
121 info.GetReturnValue().Set(42);
122 }
123
124
120 // Tests that call v8::V8::Dispose() cannot be threaded. 125 // Tests that call v8::V8::Dispose() cannot be threaded.
121 UNINITIALIZED_TEST(InitializeAndDisposeOnce) { 126 UNINITIALIZED_TEST(InitializeAndDisposeOnce) {
122 CHECK(v8::V8::Initialize()); 127 CHECK(v8::V8::Initialize());
123 CHECK(v8::V8::Dispose()); 128 CHECK(v8::V8::Dispose());
124 } 129 }
125 130
126 131
127 // Tests that call v8::V8::Dispose() cannot be threaded. 132 // Tests that call v8::V8::Dispose() cannot be threaded.
128 UNINITIALIZED_TEST(InitializeAndDisposeMultiple) { 133 UNINITIALIZED_TEST(InitializeAndDisposeMultiple) {
129 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose()); 134 for (int i = 0; i < 3; ++i) CHECK(v8::V8::Dispose());
(...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 " {get: function(){ return this.accessor_age; }, " 2223 " {get: function(){ return this.accessor_age; }, "
2219 " set: function(v){ this.accessor_age = v; }, " 2224 " set: function(v){ this.accessor_age = v; }, "
2220 " enumerable: true, configurable: true});" 2225 " enumerable: true, configurable: true});"
2221 "child.age = 10;"); 2226 "child.age = 10;");
2222 ExpectBoolean("child.hasOwnProperty('age')", false); 2227 ExpectBoolean("child.hasOwnProperty('age')", false);
2223 ExpectInt32("child.age", 10); 2228 ExpectInt32("child.age", 10);
2224 ExpectInt32("child.accessor_age", 10); 2229 ExpectInt32("child.accessor_age", 10);
2225 } 2230 }
2226 2231
2227 2232
2233 THREADED_TEST(EmptyInterceptorDoesNotShadowApiAccessors) {
2234 v8::Isolate* isolate = CcTest::isolate();
2235 v8::HandleScope scope(isolate);
2236 Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate);
2237 auto returns_42 = FunctionTemplate::New(isolate, Returns42);
2238 parent->PrototypeTemplate()->SetAccessorProperty(v8_str("age"), returns_42);
2239 Handle<FunctionTemplate> child = FunctionTemplate::New(isolate);
2240 child->Inherit(parent);
2241 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter);
2242 LocalContext env;
2243 env->Global()->Set(v8_str("Child"), child->GetFunction());
2244 CompileRun(
2245 "var child = new Child;"
2246 "var parent = child.__proto__;");
2247 ExpectBoolean("child.hasOwnProperty('age')", false);
2248 ExpectInt32("child.age", 42);
2249 // Check interceptor followup.
2250 ExpectInt32(
2251 "var result;"
2252 "for (var i = 0; i < 4; ++i) {"
2253 " result = child.age;"
2254 "}"
2255 "result",
2256 42);
2257 }
2258
2259
2228 THREADED_TEST(EmptyInterceptorDoesNotAffectJSProperties) { 2260 THREADED_TEST(EmptyInterceptorDoesNotAffectJSProperties) {
2229 v8::Isolate* isolate = CcTest::isolate(); 2261 v8::Isolate* isolate = CcTest::isolate();
2230 v8::HandleScope scope(isolate); 2262 v8::HandleScope scope(isolate);
2231 Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate); 2263 Handle<FunctionTemplate> parent = FunctionTemplate::New(isolate);
2232 Handle<FunctionTemplate> child = FunctionTemplate::New(isolate); 2264 Handle<FunctionTemplate> child = FunctionTemplate::New(isolate);
2233 child->Inherit(parent); 2265 child->Inherit(parent);
2234 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter); 2266 AddInterceptor(child, EmptyInterceptorGetter, EmptyInterceptorSetter);
2235 LocalContext env; 2267 LocalContext env;
2236 env->Global()->Set(v8_str("Child"), child->GetFunction()); 2268 env->Global()->Set(v8_str("Child"), child->GetFunction());
2237 CompileRun("var child = new Child;" 2269 CompileRun("var child = new Child;"
(...skipping 21211 matching lines...) Expand 10 before | Expand all | Expand 10 after
23449 int ApiCallOptimizationChecker::count = 0; 23481 int ApiCallOptimizationChecker::count = 0;
23450 23482
23451 23483
23452 TEST(FunctionCallOptimization) { 23484 TEST(FunctionCallOptimization) {
23453 i::FLAG_allow_natives_syntax = true; 23485 i::FLAG_allow_natives_syntax = true;
23454 ApiCallOptimizationChecker checker; 23486 ApiCallOptimizationChecker checker;
23455 checker.RunAll(); 23487 checker.RunAll();
23456 } 23488 }
23457 23489
23458 23490
23459 static void Returns42(const v8::FunctionCallbackInfo<v8::Value>& info) {
23460 info.GetReturnValue().Set(42);
23461 }
23462
23463
23464 TEST(FunctionCallOptimizationMultipleArgs) { 23491 TEST(FunctionCallOptimizationMultipleArgs) {
23465 i::FLAG_allow_natives_syntax = true; 23492 i::FLAG_allow_natives_syntax = true;
23466 LocalContext context; 23493 LocalContext context;
23467 v8::Isolate* isolate = context->GetIsolate(); 23494 v8::Isolate* isolate = context->GetIsolate();
23468 v8::HandleScope scope(isolate); 23495 v8::HandleScope scope(isolate);
23469 Handle<Object> global = context->Global(); 23496 Handle<Object> global = context->Global();
23470 Local<v8::Function> function = Function::New(isolate, Returns42); 23497 Local<v8::Function> function = Function::New(isolate, Returns42);
23471 global->Set(v8_str("x"), function); 23498 global->Set(v8_str("x"), function);
23472 CompileRun( 23499 CompileRun(
23473 "function x_wrap() {\n" 23500 "function x_wrap() {\n"
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
24780 "bar2.js"); 24807 "bar2.js");
24781 } 24808 }
24782 24809
24783 24810
24784 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { 24811 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) {
24785 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", 24812 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#",
24786 " sourceMappingURL=bar2.js\n", "foo();", NULL}; 24813 " sourceMappingURL=bar2.js\n", "foo();", NULL};
24787 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, 24814 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL,
24788 "bar2.js"); 24815 "bar2.js");
24789 } 24816 }
OLDNEW
« no previous file with comments | « src/ic/handler-compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698