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: src/stub-cache.cc

Issue 151063003: let load and store api callbacks use global proxy as receiver (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/stub-cache.h ('k') | src/x64/stub-cache-x64.cc » ('j') | 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 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 944
945 945
946 Handle<Code> LoadStubCompiler::CompileLoadCallback( 946 Handle<Code> LoadStubCompiler::CompileLoadCallback(
947 Handle<HeapType> type, 947 Handle<HeapType> type,
948 Handle<JSObject> holder, 948 Handle<JSObject> holder,
949 Handle<Name> name, 949 Handle<Name> name,
950 const CallOptimization& call_optimization) { 950 const CallOptimization& call_optimization) {
951 ASSERT(call_optimization.is_simple_api_call()); 951 ASSERT(call_optimization.is_simple_api_call());
952 Handle<JSFunction> callback = call_optimization.constant_function(); 952 Handle<JSFunction> callback = call_optimization.constant_function();
953 CallbackHandlerFrontend(type, receiver(), holder, name, callback); 953 CallbackHandlerFrontend(type, receiver(), holder, name, callback);
954 GenerateLoadCallback(call_optimization); 954 GenerateLoadCallback(call_optimization, IC::TypeToMap(*type, isolate()));
955 955
956 // Return the generated code. 956 // Return the generated code.
957 return GetCode(kind(), Code::FAST, name); 957 return GetCode(kind(), Code::FAST, name);
958 } 958 }
959 959
960 960
961 Handle<Code> LoadStubCompiler::CompileLoadInterceptor( 961 Handle<Code> LoadStubCompiler::CompileLoadInterceptor(
962 Handle<HeapType> type, 962 Handle<HeapType> type,
963 Handle<JSObject> holder, 963 Handle<JSObject> holder,
964 Handle<Name> name) { 964 Handle<Name> name) {
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 1350
1351 CallOptimization::CallOptimization(Handle<JSFunction> function) { 1351 CallOptimization::CallOptimization(Handle<JSFunction> function) {
1352 Initialize(function); 1352 Initialize(function);
1353 } 1353 }
1354 1354
1355 1355
1356 Handle<JSObject> CallOptimization::LookupHolderOfExpectedType( 1356 Handle<JSObject> CallOptimization::LookupHolderOfExpectedType(
1357 Handle<Map> object_map, 1357 Handle<Map> object_map,
1358 HolderLookup* holder_lookup) const { 1358 HolderLookup* holder_lookup) const {
1359 ASSERT(is_simple_api_call()); 1359 ASSERT(is_simple_api_call());
1360 ASSERT_EQ(kHolderNotFound, *holder_lookup);
1361 if (!object_map->IsJSObjectMap()) { 1360 if (!object_map->IsJSObjectMap()) {
1362 *holder_lookup = kHolderNotFound; 1361 *holder_lookup = kHolderNotFound;
1363 return Handle<JSObject>::null(); 1362 return Handle<JSObject>::null();
1364 } 1363 }
1365 if (expected_receiver_type_.is_null() || 1364 if (expected_receiver_type_.is_null() ||
1366 expected_receiver_type_->IsTemplateFor(*object_map)) { 1365 expected_receiver_type_->IsTemplateFor(*object_map)) {
1367 *holder_lookup = kHolderIsReceiver; 1366 *holder_lookup = kHolderIsReceiver;
1368 return Handle<JSObject>::null(); 1367 return Handle<JSObject>::null();
1369 } 1368 }
1370 while (true) { 1369 while (true) {
1371 if (!object_map->prototype()->IsJSObject()) break; 1370 if (!object_map->prototype()->IsJSObject()) break;
1372 Handle<JSObject> prototype(JSObject::cast(object_map->prototype())); 1371 Handle<JSObject> prototype(JSObject::cast(object_map->prototype()));
1373 if (!prototype->map()->is_hidden_prototype()) break; 1372 if (!prototype->map()->is_hidden_prototype()) break;
1374 object_map = handle(prototype->map()); 1373 object_map = handle(prototype->map());
1375 if (expected_receiver_type_->IsTemplateFor(*object_map)) { 1374 if (expected_receiver_type_->IsTemplateFor(*object_map)) {
1376 *holder_lookup = kHolderFound; 1375 *holder_lookup = kHolderFound;
1377 return prototype; 1376 return prototype;
1378 } 1377 }
1379 } 1378 }
1380 *holder_lookup = kHolderNotFound; 1379 *holder_lookup = kHolderNotFound;
1381 return Handle<JSObject>::null(); 1380 return Handle<JSObject>::null();
1382 } 1381 }
1383 1382
1384 1383
1384 bool CallOptimization::IsCompatibleReceiver(Handle<Object> receiver,
1385 Handle<JSObject> holder) const {
1386 ASSERT(is_simple_api_call());
1387 if (!receiver->IsJSObject()) return false;
1388 Handle<Map> map(JSObject::cast(*receiver)->map());
1389 HolderLookup holder_lookup;
1390 Handle<JSObject> api_holder =
1391 LookupHolderOfExpectedType(map, &holder_lookup);
1392 switch (holder_lookup) {
1393 case kHolderNotFound:
1394 return false;
1395 case kHolderIsReceiver:
1396 return true;
1397 case kHolderFound:
1398 if (api_holder.is_identical_to(holder)) return true;
1399 // Check if holder is in prototype chain of api_holder.
1400 {
1401 JSObject* object = *api_holder;
1402 while (true) {
1403 Object* prototype = object->map()->prototype();
1404 if (!prototype->IsJSObject()) return false;
1405 if (prototype == *holder) return true;
1406 object = JSObject::cast(prototype);
1407 }
1408 }
1409 break;
1410 }
1411 UNREACHABLE();
1412 return false;
1413 }
1414
1415
1385 void CallOptimization::Initialize(Handle<JSFunction> function) { 1416 void CallOptimization::Initialize(Handle<JSFunction> function) {
1386 constant_function_ = Handle<JSFunction>::null(); 1417 constant_function_ = Handle<JSFunction>::null();
1387 is_simple_api_call_ = false; 1418 is_simple_api_call_ = false;
1388 expected_receiver_type_ = Handle<FunctionTemplateInfo>::null(); 1419 expected_receiver_type_ = Handle<FunctionTemplateInfo>::null();
1389 api_call_info_ = Handle<CallHandlerInfo>::null(); 1420 api_call_info_ = Handle<CallHandlerInfo>::null();
1390 1421
1391 if (function.is_null() || !function->is_compiled()) return; 1422 if (function.is_null() || !function->is_compiled()) return;
1392 1423
1393 constant_function_ = function; 1424 constant_function_ = function;
1394 AnalyzePossibleApiFunction(function); 1425 AnalyzePossibleApiFunction(function);
(...skipping 20 matching lines...) Expand all
1415 Handle<FunctionTemplateInfo>( 1446 Handle<FunctionTemplateInfo>(
1416 FunctionTemplateInfo::cast(signature->receiver())); 1447 FunctionTemplateInfo::cast(signature->receiver()));
1417 } 1448 }
1418 } 1449 }
1419 1450
1420 is_simple_api_call_ = true; 1451 is_simple_api_call_ = true;
1421 } 1452 }
1422 1453
1423 1454
1424 } } // namespace v8::internal 1455 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/stub-cache.h ('k') | src/x64/stub-cache-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698