OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 PatchInlinedStore(address, Heap::fixed_array_map()); | 360 PatchInlinedStore(address, Heap::fixed_array_map()); |
361 } | 361 } |
362 | 362 |
363 | 363 |
364 void KeyedStoreIC::Clear(Address address, Code* target) { | 364 void KeyedStoreIC::Clear(Address address, Code* target) { |
365 if (target->ic_state() == UNINITIALIZED) return; | 365 if (target->ic_state() == UNINITIALIZED) return; |
366 SetTargetAtAddress(address, initialize_stub()); | 366 SetTargetAtAddress(address, initialize_stub()); |
367 } | 367 } |
368 | 368 |
369 | 369 |
370 Code* KeyedLoadIC::external_array_stub(JSObject::ElementsKind elements_kind) { | |
371 switch (elements_kind) { | |
372 case JSObject::EXTERNAL_BYTE_ELEMENTS: | |
373 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalByteArray); | |
374 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | |
375 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalUnsignedByteArray); | |
376 case JSObject::EXTERNAL_SHORT_ELEMENTS: | |
377 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalShortArray); | |
378 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | |
379 return Builtins::builtin( | |
380 Builtins::KeyedLoadIC_ExternalUnsignedShortArray); | |
381 case JSObject::EXTERNAL_INT_ELEMENTS: | |
382 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalIntArray); | |
383 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | |
384 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalUnsignedIntArray); | |
385 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | |
386 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalFloatArray); | |
387 default: | |
388 UNREACHABLE(); | |
389 return NULL; | |
390 } | |
391 } | |
392 | |
393 | |
394 Code* KeyedStoreIC::external_array_stub(JSObject::ElementsKind elements_kind) { | |
395 switch (elements_kind) { | |
396 case JSObject::EXTERNAL_BYTE_ELEMENTS: | |
397 return Builtins::builtin(Builtins::KeyedStoreIC_ExternalByteArray); | |
398 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | |
399 return Builtins::builtin( | |
400 Builtins::KeyedStoreIC_ExternalUnsignedByteArray); | |
401 case JSObject::EXTERNAL_SHORT_ELEMENTS: | |
402 return Builtins::builtin(Builtins::KeyedStoreIC_ExternalShortArray); | |
403 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | |
404 return Builtins::builtin( | |
405 Builtins::KeyedStoreIC_ExternalUnsignedShortArray); | |
406 case JSObject::EXTERNAL_INT_ELEMENTS: | |
407 return Builtins::builtin(Builtins::KeyedStoreIC_ExternalIntArray); | |
408 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | |
409 return Builtins::builtin(Builtins::KeyedStoreIC_ExternalUnsignedIntArray); | |
410 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | |
411 return Builtins::builtin(Builtins::KeyedStoreIC_ExternalFloatArray); | |
412 default: | |
413 UNREACHABLE(); | |
414 return NULL; | |
415 } | |
416 } | |
417 | |
418 | |
419 static bool HasInterceptorGetter(JSObject* object) { | 370 static bool HasInterceptorGetter(JSObject* object) { |
420 return !object->GetNamedInterceptor()->getter()->IsUndefined(); | 371 return !object->GetNamedInterceptor()->getter()->IsUndefined(); |
421 } | 372 } |
422 | 373 |
423 | 374 |
424 static void LookupForRead(Object* object, | 375 static void LookupForRead(Object* object, |
425 String* name, | 376 String* name, |
426 LookupResult* lookup) { | 377 LookupResult* lookup) { |
427 AssertNoAllocation no_gc; // pointers must stay valid | 378 AssertNoAllocation no_gc; // pointers must stay valid |
428 | 379 |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 // the global object). | 1187 // the global object). |
1237 bool use_ic = FLAG_use_ic && !object->IsAccessCheckNeeded(); | 1188 bool use_ic = FLAG_use_ic && !object->IsAccessCheckNeeded(); |
1238 | 1189 |
1239 if (use_ic) { | 1190 if (use_ic) { |
1240 Code* stub = generic_stub(); | 1191 Code* stub = generic_stub(); |
1241 if (object->IsString() && key->IsNumber()) { | 1192 if (object->IsString() && key->IsNumber()) { |
1242 stub = string_stub(); | 1193 stub = string_stub(); |
1243 } else if (object->IsJSObject()) { | 1194 } else if (object->IsJSObject()) { |
1244 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1195 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
1245 if (receiver->HasExternalArrayElements()) { | 1196 if (receiver->HasExternalArrayElements()) { |
1246 stub = external_array_stub(receiver->GetElementsKind()); | 1197 MaybeObject* probe = |
| 1198 StubCache::ComputeKeyedLoadOrStoreExternalArray(*receiver, false); |
| 1199 stub = |
| 1200 probe->IsFailure() ? NULL : Code::cast(probe->ToObjectUnchecked()); |
1247 } else if (receiver->HasIndexedInterceptor()) { | 1201 } else if (receiver->HasIndexedInterceptor()) { |
1248 stub = indexed_interceptor_stub(); | 1202 stub = indexed_interceptor_stub(); |
1249 } else if (state == UNINITIALIZED && | 1203 } else if (state == UNINITIALIZED && |
1250 key->IsSmi() && | 1204 key->IsSmi() && |
1251 receiver->map()->has_fast_elements()) { | 1205 receiver->map()->has_fast_elements()) { |
1252 MaybeObject* probe = StubCache::ComputeKeyedLoadSpecialized(*receiver); | 1206 MaybeObject* probe = StubCache::ComputeKeyedLoadSpecialized(*receiver); |
1253 stub = | 1207 stub = |
1254 probe->IsFailure() ? NULL : Code::cast(probe->ToObjectUnchecked()); | 1208 probe->IsFailure() ? NULL : Code::cast(probe->ToObjectUnchecked()); |
1255 } | 1209 } |
1256 } | 1210 } |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 // Do not use ICs for objects that require access checks (including | 1583 // Do not use ICs for objects that require access checks (including |
1630 // the global object). | 1584 // the global object). |
1631 bool use_ic = FLAG_use_ic && !object->IsAccessCheckNeeded(); | 1585 bool use_ic = FLAG_use_ic && !object->IsAccessCheckNeeded(); |
1632 ASSERT(!(use_ic && object->IsJSGlobalProxy())); | 1586 ASSERT(!(use_ic && object->IsJSGlobalProxy())); |
1633 | 1587 |
1634 if (use_ic) { | 1588 if (use_ic) { |
1635 Code* stub = generic_stub(); | 1589 Code* stub = generic_stub(); |
1636 if (object->IsJSObject()) { | 1590 if (object->IsJSObject()) { |
1637 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 1591 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
1638 if (receiver->HasExternalArrayElements()) { | 1592 if (receiver->HasExternalArrayElements()) { |
1639 stub = external_array_stub(receiver->GetElementsKind()); | 1593 MaybeObject* probe = |
| 1594 StubCache::ComputeKeyedLoadOrStoreExternalArray(*receiver, true); |
| 1595 stub = |
| 1596 probe->IsFailure() ? NULL : Code::cast(probe->ToObjectUnchecked()); |
1640 } else if (state == UNINITIALIZED && | 1597 } else if (state == UNINITIALIZED && |
1641 key->IsSmi() && | 1598 key->IsSmi() && |
1642 receiver->map()->has_fast_elements()) { | 1599 receiver->map()->has_fast_elements()) { |
1643 MaybeObject* probe = StubCache::ComputeKeyedStoreSpecialized(*receiver); | 1600 MaybeObject* probe = StubCache::ComputeKeyedStoreSpecialized(*receiver); |
1644 stub = | 1601 stub = |
1645 probe->IsFailure() ? NULL : Code::cast(probe->ToObjectUnchecked()); | 1602 probe->IsFailure() ? NULL : Code::cast(probe->ToObjectUnchecked()); |
1646 } | 1603 } |
1647 } | 1604 } |
1648 if (stub != NULL) set_target(stub); | 1605 if (stub != NULL) set_target(stub); |
1649 } | 1606 } |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2273 #undef ADDR | 2230 #undef ADDR |
2274 }; | 2231 }; |
2275 | 2232 |
2276 | 2233 |
2277 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2234 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2278 return IC_utilities[id]; | 2235 return IC_utilities[id]; |
2279 } | 2236 } |
2280 | 2237 |
2281 | 2238 |
2282 } } // namespace v8::internal | 2239 } } // namespace v8::internal |
OLD | NEW |