OLD | NEW |
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 Loading... |
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, | 1321 name, receiver, holder, Code::LOAD_IC, |
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, constant); | 1329 name, receiver, holder, Code::LOAD_IC, 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, info); | 1353 name, receiver, holder, Code::LOAD_IC, 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 return isolate()->stub_cache()->ComputeLoadCallback( | 1364 return isolate()->stub_cache()->ComputeLoadCallback( |
1365 name, receiver, holder, call_optimization); | 1365 name, receiver, holder, Code::LOAD_IC, call_optimization); |
1366 } | 1366 } |
1367 return isolate()->stub_cache()->ComputeLoadViaGetter( | 1367 return isolate()->stub_cache()->ComputeLoadViaGetter( |
1368 name, receiver, holder, function); | 1368 name, receiver, holder, function); |
1369 } else if (receiver->IsJSArray() && | 1369 } else if (receiver->IsJSArray() && |
1370 name->Equals(isolate()->heap()->length_string())) { | 1370 name->Equals(isolate()->heap()->length_string())) { |
1371 PropertyIndex lengthIndex = | 1371 PropertyIndex lengthIndex = |
1372 PropertyIndex::NewHeaderIndex(JSArray::kLengthOffset / kPointerSize); | 1372 PropertyIndex::NewHeaderIndex(JSArray::kLengthOffset / kPointerSize); |
1373 return isolate()->stub_cache()->ComputeLoadField( | 1373 return isolate()->stub_cache()->ComputeLoadField( |
1374 name, receiver, holder, lengthIndex, Representation::Tagged()); | 1374 name, receiver, holder, Code::LOAD_IC, |
| 1375 lengthIndex, Representation::Tagged()); |
1375 } | 1376 } |
1376 // TODO(dcarney): Handle correctly. | 1377 // TODO(dcarney): Handle correctly. |
1377 if (callback->IsDeclaredAccessorInfo()) break; | 1378 if (callback->IsDeclaredAccessorInfo()) break; |
1378 ASSERT(callback->IsForeign()); | 1379 ASSERT(callback->IsForeign()); |
1379 // No IC support for old-style native accessors. | 1380 // No IC support for old-style native accessors. |
1380 break; | 1381 break; |
1381 } | 1382 } |
1382 case INTERCEPTOR: | 1383 case INTERCEPTOR: |
1383 ASSERT(HasInterceptorGetter(*holder)); | 1384 ASSERT(HasInterceptorGetter(*holder)); |
1384 return isolate()->stub_cache()->ComputeLoadInterceptor( | 1385 return isolate()->stub_cache()->ComputeLoadInterceptor( |
1385 name, receiver, holder); | 1386 name, receiver, holder, Code::LOAD_IC); |
1386 default: | 1387 default: |
1387 break; | 1388 break; |
1388 } | 1389 } |
1389 return Handle<Code>::null(); | 1390 return Handle<Code>::null(); |
1390 } | 1391 } |
1391 | 1392 |
1392 | 1393 |
1393 static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) { | 1394 static Handle<Object> TryConvertKey(Handle<Object> key, Isolate* isolate) { |
1394 // This helper implements a few common fast cases for converting | 1395 // This helper implements a few common fast cases for converting |
1395 // 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 Loading... |
1530 Handle<Code> KeyedLoadIC::ComputeLoadHandler(LookupResult* lookup, | 1531 Handle<Code> KeyedLoadIC::ComputeLoadHandler(LookupResult* lookup, |
1531 Handle<JSObject> receiver, | 1532 Handle<JSObject> receiver, |
1532 Handle<String> name) { | 1533 Handle<String> name) { |
1533 // Bail out if we didn't find a result. | 1534 // Bail out if we didn't find a result. |
1534 if (!lookup->IsProperty()) return Handle<Code>::null(); | 1535 if (!lookup->IsProperty()) return Handle<Code>::null(); |
1535 | 1536 |
1536 // Compute a monomorphic stub. | 1537 // Compute a monomorphic stub. |
1537 Handle<JSObject> holder(lookup->holder(), isolate()); | 1538 Handle<JSObject> holder(lookup->holder(), isolate()); |
1538 switch (lookup->type()) { | 1539 switch (lookup->type()) { |
1539 case FIELD: | 1540 case FIELD: |
1540 return isolate()->stub_cache()->ComputeKeyedLoadField( | 1541 return isolate()->stub_cache()->ComputeLoadField( |
1541 name, receiver, holder, | 1542 name, receiver, holder, Code::KEYED_LOAD_IC, |
1542 lookup->GetFieldIndex(), lookup->representation()); | 1543 lookup->GetFieldIndex(), lookup->representation()); |
1543 case CONSTANT: { | 1544 case CONSTANT: { |
1544 Handle<Object> constant(lookup->GetConstant(), isolate()); | 1545 Handle<Object> constant(lookup->GetConstant(), isolate()); |
1545 // 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 |
1546 // be embedded into code. | 1547 // be embedded into code. |
1547 if (constant->IsConsString()) return Handle<Code>::null(); | 1548 if (constant->IsConsString()) return Handle<Code>::null(); |
1548 return isolate()->stub_cache()->ComputeKeyedLoadConstant( | 1549 return isolate()->stub_cache()->ComputeLoadConstant( |
1549 name, receiver, holder, constant); | 1550 name, receiver, holder, Code::KEYED_LOAD_IC, constant); |
1550 } | 1551 } |
1551 case CALLBACKS: { | 1552 case CALLBACKS: { |
1552 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate()); | 1553 Handle<Object> callback_object(lookup->GetCallbackObject(), isolate()); |
1553 // TODO(dcarney): Handle DeclaredAccessorInfo correctly. | 1554 // TODO(dcarney): Handle DeclaredAccessorInfo correctly. |
1554 if (callback_object->IsExecutableAccessorInfo()) { | 1555 if (callback_object->IsExecutableAccessorInfo()) { |
1555 Handle<ExecutableAccessorInfo> callback = | 1556 Handle<ExecutableAccessorInfo> callback = |
1556 Handle<ExecutableAccessorInfo>::cast(callback_object); | 1557 Handle<ExecutableAccessorInfo>::cast(callback_object); |
1557 if (v8::ToCData<Address>(callback->getter()) == 0) break; | 1558 if (v8::ToCData<Address>(callback->getter()) == 0) break; |
1558 if (!callback->IsCompatibleReceiver(*receiver)) break; | 1559 if (!callback->IsCompatibleReceiver(*receiver)) break; |
1559 return isolate()->stub_cache()->ComputeKeyedLoadCallback( | 1560 return isolate()->stub_cache()->ComputeLoadCallback( |
1560 name, receiver, holder, callback); | 1561 name, receiver, holder, Code::KEYED_LOAD_IC, callback); |
1561 } else if (callback_object->IsAccessorPair()) { | 1562 } else if (callback_object->IsAccessorPair()) { |
1562 Handle<Object> getter( | 1563 Handle<Object> getter( |
1563 Handle<AccessorPair>::cast(callback_object)->getter(), | 1564 Handle<AccessorPair>::cast(callback_object)->getter(), |
1564 isolate()); | 1565 isolate()); |
1565 if (!getter->IsJSFunction()) break; | 1566 if (!getter->IsJSFunction()) break; |
1566 if (holder->IsGlobalObject()) break; | 1567 if (holder->IsGlobalObject()) break; |
1567 if (!holder->HasFastProperties()) break; | 1568 if (!holder->HasFastProperties()) break; |
1568 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); | 1569 Handle<JSFunction> function = Handle<JSFunction>::cast(getter); |
1569 CallOptimization call_optimization(function); | 1570 CallOptimization call_optimization(function); |
1570 if (call_optimization.is_simple_api_call() && | 1571 if (call_optimization.is_simple_api_call() && |
1571 call_optimization.IsCompatibleReceiver(*receiver)) { | 1572 call_optimization.IsCompatibleReceiver(*receiver)) { |
1572 return isolate()->stub_cache()->ComputeKeyedLoadCallback( | 1573 return isolate()->stub_cache()->ComputeLoadCallback( |
1573 name, receiver, holder, call_optimization); | 1574 name, receiver, holder, Code::KEYED_LOAD_IC, call_optimization); |
1574 } | 1575 } |
1575 } | 1576 } |
1576 break; | 1577 break; |
1577 } | 1578 } |
1578 case INTERCEPTOR: | 1579 case INTERCEPTOR: |
1579 ASSERT(HasInterceptorGetter(lookup->holder())); | 1580 ASSERT(HasInterceptorGetter(lookup->holder())); |
1580 return isolate()->stub_cache()->ComputeKeyedLoadInterceptor( | 1581 return isolate()->stub_cache()->ComputeLoadInterceptor( |
1581 name, receiver, holder); | 1582 name, receiver, holder, Code::KEYED_LOAD_IC); |
1582 default: | 1583 default: |
1583 // Always rewrite to the generic case so that we do not | 1584 // Always rewrite to the generic case so that we do not |
1584 // repeatedly try to rewrite. | 1585 // repeatedly try to rewrite. |
1585 return generic_stub(); | 1586 return generic_stub(); |
1586 } | 1587 } |
1587 return Handle<Code>::null(); | 1588 return Handle<Code>::null(); |
1588 } | 1589 } |
1589 | 1590 |
1590 | 1591 |
1591 static bool LookupForWrite(Handle<JSObject> receiver, | 1592 static bool LookupForWrite(Handle<JSObject> receiver, |
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3129 #undef ADDR | 3130 #undef ADDR |
3130 }; | 3131 }; |
3131 | 3132 |
3132 | 3133 |
3133 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3134 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
3134 return IC_utilities[id]; | 3135 return IC_utilities[id]; |
3135 } | 3136 } |
3136 | 3137 |
3137 | 3138 |
3138 } } // namespace v8::internal | 3139 } } // namespace v8::internal |
OLD | NEW |