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

Side by Side Diff: src/ic.cc

Issue 24095005: Revert "Unify computation of load stubs in stub cache." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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 | « no previous file | src/stub-cache.h » ('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 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 if (!lookup->IsProperty()) { 1311 if (!lookup->IsProperty()) {
1312 // Nonexistent property. The result is undefined. 1312 // Nonexistent property. The result is undefined.
1313 return isolate()->stub_cache()->ComputeLoadNonexistent(name, receiver); 1313 return isolate()->stub_cache()->ComputeLoadNonexistent(name, receiver);
1314 } 1314 }
1315 1315
1316 // Compute monomorphic stub. 1316 // Compute monomorphic stub.
1317 Handle<JSObject> holder(lookup->holder()); 1317 Handle<JSObject> holder(lookup->holder());
1318 switch (lookup->type()) { 1318 switch (lookup->type()) {
1319 case FIELD: 1319 case FIELD:
1320 return isolate()->stub_cache()->ComputeLoadField( 1320 return isolate()->stub_cache()->ComputeLoadField(
1321 name, receiver, holder, Code::LOAD_IC, 1321 name, receiver, holder,
1322 lookup->GetFieldIndex(), lookup->representation()); 1322 lookup->GetFieldIndex(), lookup->representation());
1323 case CONSTANT: { 1323 case CONSTANT: {
1324 Handle<Object> constant(lookup->GetConstant(), isolate()); 1324 Handle<Object> constant(lookup->GetConstant(), isolate());
1325 // TODO(2803): Don't compute a stub for cons strings because they cannot 1325 // TODO(2803): Don't compute a stub for cons strings because they cannot
1326 // be embedded into code. 1326 // be embedded into code.
1327 if (constant->IsConsString()) return Handle<Code>::null(); 1327 if (constant->IsConsString()) return Handle<Code>::null();
1328 return isolate()->stub_cache()->ComputeLoadConstant( 1328 return isolate()->stub_cache()->ComputeLoadConstant(
1329 name, receiver, holder, Code::LOAD_IC, constant); 1329 name, receiver, holder, constant);
1330 } 1330 }
1331 case NORMAL: 1331 case NORMAL:
1332 if (holder->IsGlobalObject()) { 1332 if (holder->IsGlobalObject()) {
1333 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder); 1333 Handle<GlobalObject> global = Handle<GlobalObject>::cast(holder);
1334 Handle<PropertyCell> cell( 1334 Handle<PropertyCell> cell(
1335 global->GetPropertyCell(lookup), isolate()); 1335 global->GetPropertyCell(lookup), isolate());
1336 return isolate()->stub_cache()->ComputeLoadGlobal( 1336 return isolate()->stub_cache()->ComputeLoadGlobal(
1337 name, receiver, global, cell, lookup->IsDontDelete()); 1337 name, receiver, global, cell, lookup->IsDontDelete());
1338 } 1338 }
1339 // There is only one shared stub for loading normalized 1339 // There is only one shared stub for loading normalized
1340 // properties. It does not traverse the prototype chain, so the 1340 // properties. It does not traverse the prototype chain, so the
1341 // property must be found in the receiver for the stub to be 1341 // property must be found in the receiver for the stub to be
1342 // applicable. 1342 // applicable.
1343 if (!holder.is_identical_to(receiver)) break; 1343 if (!holder.is_identical_to(receiver)) break;
1344 return isolate()->stub_cache()->ComputeLoadNormal(name, receiver); 1344 return isolate()->stub_cache()->ComputeLoadNormal(name, receiver);
1345 case CALLBACKS: { 1345 case CALLBACKS: {
1346 Handle<Object> callback(lookup->GetCallbackObject(), isolate()); 1346 Handle<Object> callback(lookup->GetCallbackObject(), isolate());
1347 if (callback->IsExecutableAccessorInfo()) { 1347 if (callback->IsExecutableAccessorInfo()) {
1348 Handle<ExecutableAccessorInfo> info = 1348 Handle<ExecutableAccessorInfo> info =
1349 Handle<ExecutableAccessorInfo>::cast(callback); 1349 Handle<ExecutableAccessorInfo>::cast(callback);
1350 if (v8::ToCData<Address>(info->getter()) == 0) break; 1350 if (v8::ToCData<Address>(info->getter()) == 0) break;
1351 if (!info->IsCompatibleReceiver(*receiver)) break; 1351 if (!info->IsCompatibleReceiver(*receiver)) break;
1352 return isolate()->stub_cache()->ComputeLoadCallback( 1352 return isolate()->stub_cache()->ComputeLoadCallback(
1353 name, receiver, holder, Code::LOAD_IC, info); 1353 name, receiver, holder, info);
1354 } else if (callback->IsAccessorPair()) { 1354 } else if (callback->IsAccessorPair()) {
1355 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter(), 1355 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter(),
1356 isolate()); 1356 isolate());
1357 if (!getter->IsJSFunction()) break; 1357 if (!getter->IsJSFunction()) break;
1358 if (holder->IsGlobalObject()) break; 1358 if (holder->IsGlobalObject()) break;
1359 if (!holder->HasFastProperties()) break; 1359 if (!holder->HasFastProperties()) break;
1360 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); 1360 Handle<JSFunction> function = Handle<JSFunction>::cast(getter);
1361 CallOptimization call_optimization(function); 1361 CallOptimization call_optimization(function);
1362 if (call_optimization.is_simple_api_call() && 1362 if (call_optimization.is_simple_api_call() &&
1363 call_optimization.IsCompatibleReceiver(*receiver) && 1363 call_optimization.IsCompatibleReceiver(*receiver) &&
1364 FLAG_js_accessor_ics) { 1364 FLAG_js_accessor_ics) {
1365 return isolate()->stub_cache()->ComputeLoadCallback( 1365 return isolate()->stub_cache()->ComputeLoadCallback(
1366 name, receiver, holder, Code::LOAD_IC, call_optimization); 1366 name, receiver, holder, call_optimization);
1367 } 1367 }
1368 return isolate()->stub_cache()->ComputeLoadViaGetter( 1368 return isolate()->stub_cache()->ComputeLoadViaGetter(
1369 name, receiver, holder, function); 1369 name, receiver, holder, function);
1370 } else if (receiver->IsJSArray() && 1370 } else if (receiver->IsJSArray() &&
1371 name->Equals(isolate()->heap()->length_string())) { 1371 name->Equals(isolate()->heap()->length_string())) {
1372 PropertyIndex lengthIndex = 1372 PropertyIndex lengthIndex =
1373 PropertyIndex::NewHeaderIndex(JSArray::kLengthOffset / kPointerSize); 1373 PropertyIndex::NewHeaderIndex(JSArray::kLengthOffset / kPointerSize);
1374 return isolate()->stub_cache()->ComputeLoadField( 1374 return isolate()->stub_cache()->ComputeLoadField(
1375 name, receiver, holder, Code::LOAD_IC, 1375 name, receiver, holder, lengthIndex, Representation::Tagged());
1376 lengthIndex, Representation::Tagged());
1377 } 1376 }
1378 // TODO(dcarney): Handle correctly. 1377 // TODO(dcarney): Handle correctly.
1379 if (callback->IsDeclaredAccessorInfo()) break; 1378 if (callback->IsDeclaredAccessorInfo()) break;
1380 ASSERT(callback->IsForeign()); 1379 ASSERT(callback->IsForeign());
1381 // No IC support for old-style native accessors. 1380 // No IC support for old-style native accessors.
1382 break; 1381 break;
1383 } 1382 }
1384 case INTERCEPTOR: 1383 case INTERCEPTOR:
1385 ASSERT(HasInterceptorGetter(*holder)); 1384 ASSERT(HasInterceptorGetter(*holder));
1386 return isolate()->stub_cache()->ComputeLoadInterceptor( 1385 return isolate()->stub_cache()->ComputeLoadInterceptor(
1387 name, receiver, holder, Code::LOAD_IC); 1386 name, receiver, holder);
1388 default: 1387 default:
1389 break; 1388 break;
1390 } 1389 }
1391 return Handle<Code>::null(); 1390 return Handle<Code>::null();
1392 } 1391 }
1393 1392
1394 1393
1395 static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) { 1394 static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) {
1396 // This helper implements a few common fast cases for converting 1395 // This helper implements a few common fast cases for converting
1397 // non-smi keys of keyed loads/stores to a smi or a string. 1396 // non-smi keys of keyed loads/stores to a smi or a string.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 Handle<Code> KeyedLoadIC::ComputeLoadHandler(LookupResult* lookup, 1531 Handle<Code> KeyedLoadIC::ComputeLoadHandler(LookupResult* lookup,
1533 Handle<JSObject> receiver, 1532 Handle<JSObject> receiver,
1534 Handle<String> name) { 1533 Handle<String> name) {
1535 // Bail out if we didn't find a result. 1534 // Bail out if we didn't find a result.
1536 if (!lookup->IsProperty()) return Handle<Code>::null(); 1535 if (!lookup->IsProperty()) return Handle<Code>::null();
1537 1536
1538 // Compute a monomorphic stub. 1537 // Compute a monomorphic stub.
1539 Handle<JSObject> holder(lookup->holder(), isolate()); 1538 Handle<JSObject> holder(lookup->holder(), isolate());
1540 switch (lookup->type()) { 1539 switch (lookup->type()) {
1541 case FIELD: 1540 case FIELD:
1542 return isolate()->stub_cache()->ComputeLoadField( 1541 return isolate()->stub_cache()->ComputeKeyedLoadField(
1543 name, receiver, holder, Code::KEYED_LOAD_IC, 1542 name, receiver, holder,
1544 lookup->GetFieldIndex(), lookup->representation()); 1543 lookup->GetFieldIndex(), lookup->representation());
1545 case CONSTANT: { 1544 case CONSTANT: {
1546 Handle<Object> constant(lookup->GetConstant(), isolate()); 1545 Handle<Object> constant(lookup->GetConstant(), isolate());
1547 // TODO(2803): Don't compute a stub for cons strings because they cannot 1546 // TODO(2803): Don't compute a stub for cons strings because they cannot
1548 // be embedded into code. 1547 // be embedded into code.
1549 if (constant->IsConsString()) return Handle<Code>::null(); 1548 if (constant->IsConsString()) return Handle<Code>::null();
1550 return isolate()->stub_cache()->ComputeLoadConstant( 1549 return isolate()->stub_cache()->ComputeKeyedLoadConstant(
1551 name, receiver, holder, Code::KEYED_LOAD_IC, constant); 1550 name, receiver, holder, constant);
1552 } 1551 }
1553 case CALLBACKS: { 1552 case CALLBACKS: {
1554 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate()); 1553 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate());
1555 // TODO(dcarney): Handle DeclaredAccessorInfo correctly. 1554 // TODO(dcarney): Handle DeclaredAccessorInfo correctly.
1556 if (callback_object->IsExecutableAccessorInfo()) { 1555 if (callback_object->IsExecutableAccessorInfo()) {
1557 Handle<ExecutableAccessorInfo> callback = 1556 Handle<ExecutableAccessorInfo> callback =
1558 Handle<ExecutableAccessorInfo>::cast(callback_object); 1557 Handle<ExecutableAccessorInfo>::cast(callback_object);
1559 if (v8::ToCData<Address>(callback->getter()) == 0) break; 1558 if (v8::ToCData<Address>(callback->getter()) == 0) break;
1560 if (!callback->IsCompatibleReceiver(*receiver)) break; 1559 if (!callback->IsCompatibleReceiver(*receiver)) break;
1561 return isolate()->stub_cache()->ComputeLoadCallback( 1560 return isolate()->stub_cache()->ComputeKeyedLoadCallback(
1562 name, receiver, holder, Code::KEYED_LOAD_IC, callback); 1561 name, receiver, holder, callback);
1563 } else if (callback_object->IsAccessorPair()) { 1562 } else if (callback_object->IsAccessorPair()) {
1564 Handle<Object> getter( 1563 Handle<Object> getter(
1565 Handle<AccessorPair>::cast(callback_object)->getter(), 1564 Handle<AccessorPair>::cast(callback_object)->getter(),
1566 isolate()); 1565 isolate());
1567 if (!getter->IsJSFunction()) break; 1566 if (!getter->IsJSFunction()) break;
1568 if (holder->IsGlobalObject()) break; 1567 if (holder->IsGlobalObject()) break;
1569 if (!holder->HasFastProperties()) break; 1568 if (!holder->HasFastProperties()) break;
1570 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); 1569 Handle<JSFunction> function = Handle<JSFunction>::cast(getter);
1571 CallOptimization call_optimization(function); 1570 CallOptimization call_optimization(function);
1572 if (call_optimization.is_simple_api_call() && 1571 if (call_optimization.is_simple_api_call() &&
1573 call_optimization.IsCompatibleReceiver(*receiver) && 1572 call_optimization.IsCompatibleReceiver(*receiver) &&
1574 FLAG_js_accessor_ics) { 1573 FLAG_js_accessor_ics) {
1575 return isolate()->stub_cache()->ComputeLoadCallback( 1574 return isolate()->stub_cache()->ComputeKeyedLoadCallback(
1576 name, receiver, holder, Code::KEYED_LOAD_IC, call_optimization); 1575 name, receiver, holder, call_optimization);
1577 } 1576 }
1578 } 1577 }
1579 break; 1578 break;
1580 } 1579 }
1581 case INTERCEPTOR: 1580 case INTERCEPTOR:
1582 ASSERT(HasInterceptorGetter(lookup->holder())); 1581 ASSERT(HasInterceptorGetter(lookup->holder()));
1583 return isolate()->stub_cache()->ComputeLoadInterceptor( 1582 return isolate()->stub_cache()->ComputeKeyedLoadInterceptor(
1584 name, receiver, holder, Code::KEYED_LOAD_IC); 1583 name, receiver, holder);
1585 default: 1584 default:
1586 // Always rewrite to the generic case so that we do not 1585 // Always rewrite to the generic case so that we do not
1587 // repeatedly try to rewrite. 1586 // repeatedly try to rewrite.
1588 return generic_stub(); 1587 return generic_stub();
1589 } 1588 }
1590 return Handle<Code>::null(); 1589 return Handle<Code>::null();
1591 } 1590 }
1592 1591
1593 1592
1594 static bool LookupForWrite(Handle<JSObject> receiver, 1593 static bool LookupForWrite(Handle<JSObject> receiver,
(...skipping 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after
3140 #undef ADDR 3139 #undef ADDR
3141 }; 3140 };
3142 3141
3143 3142
3144 Address IC::AddressFromUtilityId(IC::UtilityId id) { 3143 Address IC::AddressFromUtilityId(IC::UtilityId id) {
3145 return IC_utilities[id]; 3144 return IC_utilities[id];
3146 } 3145 }
3147 3146
3148 3147
3149 } } // namespace v8::internal 3148 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/stub-cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698