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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 272 |
273 void KeyedStoreIC::Clear(Address address, Code* target) { | 273 void KeyedStoreIC::Clear(Address address, Code* target) { |
274 if (target->ic_state() == UNINITIALIZED) return; | 274 if (target->ic_state() == UNINITIALIZED) return; |
275 SetTargetAtAddress(address, initialize_stub()); | 275 SetTargetAtAddress(address, initialize_stub()); |
276 } | 276 } |
277 | 277 |
278 | 278 |
279 Code* KeyedLoadIC::external_array_stub(JSObject::ElementsKind elements_kind) { | 279 Code* KeyedLoadIC::external_array_stub(JSObject::ElementsKind elements_kind) { |
280 switch (elements_kind) { | 280 switch (elements_kind) { |
281 case JSObject::EXTERNAL_BYTE_ELEMENTS: | 281 case JSObject::EXTERNAL_BYTE_ELEMENTS: |
282 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalByteArray); | 282 return Isolate::Current()->builtins()->builtin( |
| 283 Builtins::KeyedLoadIC_ExternalByteArray); |
283 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 284 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
284 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalUnsignedByteArray); | 285 return Isolate::Current()->builtins()->builtin( |
| 286 Builtins::KeyedLoadIC_ExternalUnsignedByteArray); |
285 case JSObject::EXTERNAL_SHORT_ELEMENTS: | 287 case JSObject::EXTERNAL_SHORT_ELEMENTS: |
286 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalShortArray); | 288 return Isolate::Current()->builtins()->builtin( |
| 289 Builtins::KeyedLoadIC_ExternalShortArray); |
287 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 290 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
288 return Builtins::builtin( | 291 return Isolate::Current()->builtins()->builtin( |
289 Builtins::KeyedLoadIC_ExternalUnsignedShortArray); | 292 Builtins::KeyedLoadIC_ExternalUnsignedShortArray); |
290 case JSObject::EXTERNAL_INT_ELEMENTS: | 293 case JSObject::EXTERNAL_INT_ELEMENTS: |
291 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalIntArray); | 294 return Isolate::Current()->builtins()->builtin( |
| 295 Builtins::KeyedLoadIC_ExternalIntArray); |
292 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | 296 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
293 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalUnsignedIntArray); | 297 return Isolate::Current()->builtins()->builtin( |
| 298 Builtins::KeyedLoadIC_ExternalUnsignedIntArray); |
294 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | 299 case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
295 return Builtins::builtin(Builtins::KeyedLoadIC_ExternalFloatArray); | 300 return Isolate::Current()->builtins()->builtin( |
| 301 Builtins::KeyedLoadIC_ExternalFloatArray); |
296 default: | 302 default: |
297 UNREACHABLE(); | 303 UNREACHABLE(); |
298 return NULL; | 304 return NULL; |
299 } | 305 } |
300 } | 306 } |
301 | 307 |
302 | 308 |
303 Code* KeyedStoreIC::external_array_stub(JSObject::ElementsKind elements_kind) { | 309 Code* KeyedStoreIC::external_array_stub(JSObject::ElementsKind elements_kind) { |
304 switch (elements_kind) { | 310 switch (elements_kind) { |
305 case JSObject::EXTERNAL_BYTE_ELEMENTS: | 311 case JSObject::EXTERNAL_BYTE_ELEMENTS: |
306 return Builtins::builtin(Builtins::KeyedStoreIC_ExternalByteArray); | 312 return Isolate::Current()->builtins()->builtin( |
| 313 Builtins::KeyedStoreIC_ExternalByteArray); |
307 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 314 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
308 return Builtins::builtin( | 315 return Isolate::Current()->builtins()->builtin( |
309 Builtins::KeyedStoreIC_ExternalUnsignedByteArray); | 316 Builtins::KeyedStoreIC_ExternalUnsignedByteArray); |
310 case JSObject::EXTERNAL_SHORT_ELEMENTS: | 317 case JSObject::EXTERNAL_SHORT_ELEMENTS: |
311 return Builtins::builtin(Builtins::KeyedStoreIC_ExternalShortArray); | 318 return Isolate::Current()->builtins()->builtin( |
| 319 Builtins::KeyedStoreIC_ExternalShortArray); |
312 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 320 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
313 return Builtins::builtin( | 321 return Isolate::Current()->builtins()->builtin( |
314 Builtins::KeyedStoreIC_ExternalUnsignedShortArray); | 322 Builtins::KeyedStoreIC_ExternalUnsignedShortArray); |
315 case JSObject::EXTERNAL_INT_ELEMENTS: | 323 case JSObject::EXTERNAL_INT_ELEMENTS: |
316 return Builtins::builtin(Builtins::KeyedStoreIC_ExternalIntArray); | 324 return Isolate::Current()->builtins()->builtin( |
| 325 Builtins::KeyedStoreIC_ExternalIntArray); |
317 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: | 326 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
318 return Builtins::builtin(Builtins::KeyedStoreIC_ExternalUnsignedIntArray); | 327 return Isolate::Current()->builtins()->builtin( |
| 328 Builtins::KeyedStoreIC_ExternalUnsignedIntArray); |
319 case JSObject::EXTERNAL_FLOAT_ELEMENTS: | 329 case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
320 return Builtins::builtin(Builtins::KeyedStoreIC_ExternalFloatArray); | 330 return Isolate::Current()->builtins()->builtin( |
| 331 Builtins::KeyedStoreIC_ExternalFloatArray); |
321 default: | 332 default: |
322 UNREACHABLE(); | 333 UNREACHABLE(); |
323 return NULL; | 334 return NULL; |
324 } | 335 } |
325 } | 336 } |
326 | 337 |
327 | 338 |
328 static bool HasInterceptorGetter(JSObject* object) { | 339 static bool HasInterceptorGetter(JSObject* object) { |
329 return !object->GetNamedInterceptor()->getter()->IsUndefined(); | 340 return !object->GetNamedInterceptor()->getter()->IsUndefined(); |
330 } | 341 } |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 #ifdef DEBUG | 681 #ifdef DEBUG |
671 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); | 682 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); |
672 #endif | 683 #endif |
673 Map* map = HeapObject::cast(*object)->map(); | 684 Map* map = HeapObject::cast(*object)->map(); |
674 if (object->IsString()) { | 685 if (object->IsString()) { |
675 const int offset = String::kLengthOffset; | 686 const int offset = String::kLengthOffset; |
676 PatchInlinedLoad(address(), map, offset); | 687 PatchInlinedLoad(address(), map, offset); |
677 } | 688 } |
678 | 689 |
679 Code* target = NULL; | 690 Code* target = NULL; |
680 target = Builtins::builtin(Builtins::LoadIC_StringLength); | 691 target = Isolate::Current()->builtins()->builtin( |
| 692 Builtins::LoadIC_StringLength); |
681 set_target(target); | 693 set_target(target); |
682 return Smi::FromInt(String::cast(*object)->length()); | 694 return Smi::FromInt(String::cast(*object)->length()); |
683 } | 695 } |
684 | 696 |
685 // Use specialized code for getting the length of arrays. | 697 // Use specialized code for getting the length of arrays. |
686 if (object->IsJSArray() && name->Equals(HEAP->length_symbol())) { | 698 if (object->IsJSArray() && name->Equals(HEAP->length_symbol())) { |
687 #ifdef DEBUG | 699 #ifdef DEBUG |
688 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); | 700 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); |
689 #endif | 701 #endif |
690 Map* map = HeapObject::cast(*object)->map(); | 702 Map* map = HeapObject::cast(*object)->map(); |
691 const int offset = JSArray::kLengthOffset; | 703 const int offset = JSArray::kLengthOffset; |
692 PatchInlinedLoad(address(), map, offset); | 704 PatchInlinedLoad(address(), map, offset); |
693 | 705 |
694 Code* target = Builtins::builtin(Builtins::LoadIC_ArrayLength); | 706 Code* target = Isolate::Current()->builtins()->builtin( |
| 707 Builtins::LoadIC_ArrayLength); |
695 set_target(target); | 708 set_target(target); |
696 return JSArray::cast(*object)->length(); | 709 return JSArray::cast(*object)->length(); |
697 } | 710 } |
698 | 711 |
699 // Use specialized code for getting prototype of functions. | 712 // Use specialized code for getting prototype of functions. |
700 if (object->IsJSFunction() && name->Equals(HEAP->prototype_symbol()) && | 713 if (object->IsJSFunction() && name->Equals(HEAP->prototype_symbol()) && |
701 JSFunction::cast(*object)->should_have_prototype()) { | 714 JSFunction::cast(*object)->should_have_prototype()) { |
702 #ifdef DEBUG | 715 #ifdef DEBUG |
703 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); | 716 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); |
704 #endif | 717 #endif |
705 Code* target = Builtins::builtin(Builtins::LoadIC_FunctionPrototype); | 718 Code* target = Isolate::Current()->builtins()->builtin( |
| 719 Builtins::LoadIC_FunctionPrototype); |
706 set_target(target); | 720 set_target(target); |
707 return Accessors::FunctionGetPrototype(*object, 0); | 721 return Accessors::FunctionGetPrototype(*object, 0); |
708 } | 722 } |
709 } | 723 } |
710 | 724 |
711 // Check if the name is trivially convertible to an index and get | 725 // Check if the name is trivially convertible to an index and get |
712 // the element if so. | 726 // the element if so. |
713 uint32_t index; | 727 uint32_t index; |
714 if (name->AsArrayIndex(&index)) return object->GetElement(index); | 728 if (name->AsArrayIndex(&index)) return object->GetElement(index); |
715 | 729 |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 return *value; | 1171 return *value; |
1158 } | 1172 } |
1159 | 1173 |
1160 // Use specialized code for setting the length of arrays. | 1174 // Use specialized code for setting the length of arrays. |
1161 if (receiver->IsJSArray() | 1175 if (receiver->IsJSArray() |
1162 && name->Equals(HEAP->length_symbol()) | 1176 && name->Equals(HEAP->length_symbol()) |
1163 && receiver->AllowsSetElementsLength()) { | 1177 && receiver->AllowsSetElementsLength()) { |
1164 #ifdef DEBUG | 1178 #ifdef DEBUG |
1165 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); | 1179 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); |
1166 #endif | 1180 #endif |
1167 Code* target = Builtins::builtin(Builtins::StoreIC_ArrayLength); | 1181 Code* target = Isolate::Current()->builtins()->builtin( |
| 1182 Builtins::StoreIC_ArrayLength); |
1168 set_target(target); | 1183 set_target(target); |
1169 return receiver->SetProperty(*name, *value, NONE); | 1184 return receiver->SetProperty(*name, *value, NONE); |
1170 } | 1185 } |
1171 | 1186 |
1172 // Lookup the property locally in the receiver. | 1187 // Lookup the property locally in the receiver. |
1173 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) { | 1188 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) { |
1174 LookupResult lookup; | 1189 LookupResult lookup; |
1175 if (LookupForWrite(*receiver, *name, &lookup)) { | 1190 if (LookupForWrite(*receiver, *name, &lookup)) { |
1176 UpdateCaches(&lookup, state, receiver, name, value); | 1191 UpdateCaches(&lookup, state, receiver, name, value); |
1177 } | 1192 } |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 #undef ADDR | 1671 #undef ADDR |
1657 }; | 1672 }; |
1658 | 1673 |
1659 | 1674 |
1660 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 1675 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
1661 return IC_utilities[id]; | 1676 return IC_utilities[id]; |
1662 } | 1677 } |
1663 | 1678 |
1664 | 1679 |
1665 } } // namespace v8::internal | 1680 } } // namespace v8::internal |
OLD | NEW |