| 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 492 |
| 493 // Compute the number of arguments. | 493 // Compute the number of arguments. |
| 494 int argc = target()->arguments_count(); | 494 int argc = target()->arguments_count(); |
| 495 InLoopFlag in_loop = target()->ic_in_loop(); | 495 InLoopFlag in_loop = target()->ic_in_loop(); |
| 496 Object* code = NULL; | 496 Object* code = NULL; |
| 497 | 497 |
| 498 if (state == UNINITIALIZED) { | 498 if (state == UNINITIALIZED) { |
| 499 // This is the first time we execute this inline cache. | 499 // This is the first time we execute this inline cache. |
| 500 // Set the target to the pre monomorphic stub to delay | 500 // Set the target to the pre monomorphic stub to delay |
| 501 // setting the monomorphic state. | 501 // setting the monomorphic state. |
| 502 code = StubCache::ComputeCallPreMonomorphic(argc, in_loop); | 502 code = Isolate::Current()->stub_cache()->ComputeCallPreMonomorphic(argc, |
| 503 in_loop); |
| 503 } else if (state == MONOMORPHIC) { | 504 } else if (state == MONOMORPHIC) { |
| 504 code = Isolate::Current()->stub_cache()->ComputeCallMegamorphic(argc, | 505 code = Isolate::Current()->stub_cache()->ComputeCallMegamorphic(argc, |
| 505 in_loop); | 506 in_loop); |
| 506 } else { | 507 } else { |
| 507 // Compute monomorphic stub. | 508 // Compute monomorphic stub. |
| 508 switch (lookup->type()) { | 509 switch (lookup->type()) { |
| 509 case FIELD: { | 510 case FIELD: { |
| 510 int index = lookup->GetFieldIndex(); | 511 int index = lookup->GetFieldIndex(); |
| 511 code = Isolate::Current()->stub_cache()->ComputeCallField( | 512 code = Isolate::Current()->stub_cache()->ComputeCallField( |
| 512 argc, | 513 argc, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 #endif | 618 #endif |
| 618 Map* map = HeapObject::cast(*object)->map(); | 619 Map* map = HeapObject::cast(*object)->map(); |
| 619 if (object->IsString()) { | 620 if (object->IsString()) { |
| 620 const int offset = String::kLengthOffset; | 621 const int offset = String::kLengthOffset; |
| 621 PatchInlinedLoad(address(), map, offset); | 622 PatchInlinedLoad(address(), map, offset); |
| 622 } | 623 } |
| 623 | 624 |
| 624 Code* target = NULL; | 625 Code* target = NULL; |
| 625 target = Builtins::builtin(Builtins::LoadIC_StringLength); | 626 target = Builtins::builtin(Builtins::LoadIC_StringLength); |
| 626 set_target(target); | 627 set_target(target); |
| 627 StubCache::Set(*name, map, target); | 628 Isolate::Current()->stub_cache()->Set(*name, map, target); |
| 628 return Smi::FromInt(String::cast(*object)->length()); | 629 return Smi::FromInt(String::cast(*object)->length()); |
| 629 } | 630 } |
| 630 | 631 |
| 631 // Use specialized code for getting the length of arrays. | 632 // Use specialized code for getting the length of arrays. |
| 632 if (object->IsJSArray() && name->Equals(HEAP->length_symbol())) { | 633 if (object->IsJSArray() && name->Equals(HEAP->length_symbol())) { |
| 633 #ifdef DEBUG | 634 #ifdef DEBUG |
| 634 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); | 635 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); |
| 635 #endif | 636 #endif |
| 636 Map* map = HeapObject::cast(*object)->map(); | 637 Map* map = HeapObject::cast(*object)->map(); |
| 637 const int offset = JSArray::kLengthOffset; | 638 const int offset = JSArray::kLengthOffset; |
| 638 PatchInlinedLoad(address(), map, offset); | 639 PatchInlinedLoad(address(), map, offset); |
| 639 | 640 |
| 640 Code* target = Builtins::builtin(Builtins::LoadIC_ArrayLength); | 641 Code* target = Builtins::builtin(Builtins::LoadIC_ArrayLength); |
| 641 set_target(target); | 642 set_target(target); |
| 642 StubCache::Set(*name, map, target); | 643 Isolate::Current()->stub_cache()->Set(*name, map, target); |
| 643 return JSArray::cast(*object)->length(); | 644 return JSArray::cast(*object)->length(); |
| 644 } | 645 } |
| 645 | 646 |
| 646 // Use specialized code for getting prototype of functions. | 647 // Use specialized code for getting prototype of functions. |
| 647 if (object->IsJSFunction() && name->Equals(HEAP->prototype_symbol()) && | 648 if (object->IsJSFunction() && name->Equals(HEAP->prototype_symbol()) && |
| 648 JSFunction::cast(*object)->should_have_prototype()) { | 649 JSFunction::cast(*object)->should_have_prototype()) { |
| 649 #ifdef DEBUG | 650 #ifdef DEBUG |
| 650 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); | 651 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); |
| 651 #endif | 652 #endif |
| 652 Code* target = Builtins::builtin(Builtins::LoadIC_FunctionPrototype); | 653 Code* target = Builtins::builtin(Builtins::LoadIC_FunctionPrototype); |
| 653 set_target(target); | 654 set_target(target); |
| 654 StubCache::Set(*name, HeapObject::cast(*object)->map(), target); | 655 Isolate::Current()->stub_cache()->Set(*name, |
| 656 HeapObject::cast(*object)->map(), |
| 657 target); |
| 655 return Accessors::FunctionGetPrototype(*object, 0); | 658 return Accessors::FunctionGetPrototype(*object, 0); |
| 656 } | 659 } |
| 657 } | 660 } |
| 658 | 661 |
| 659 // Check if the name is trivially convertible to an index and get | 662 // Check if the name is trivially convertible to an index and get |
| 660 // the element if so. | 663 // the element if so. |
| 661 uint32_t index; | 664 uint32_t index; |
| 662 if (name->AsArrayIndex(&index)) return object->GetElement(index); | 665 if (name->AsArrayIndex(&index)) return object->GetElement(index); |
| 663 | 666 |
| 664 // Named lookup in the object. | 667 // Named lookup in the object. |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 | 1106 |
| 1104 // Use specialized code for setting the length of arrays. | 1107 // Use specialized code for setting the length of arrays. |
| 1105 if (receiver->IsJSArray() | 1108 if (receiver->IsJSArray() |
| 1106 && name->Equals(HEAP->length_symbol()) | 1109 && name->Equals(HEAP->length_symbol()) |
| 1107 && receiver->AllowsSetElementsLength()) { | 1110 && receiver->AllowsSetElementsLength()) { |
| 1108 #ifdef DEBUG | 1111 #ifdef DEBUG |
| 1109 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); | 1112 if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n"); |
| 1110 #endif | 1113 #endif |
| 1111 Code* target = Builtins::builtin(Builtins::StoreIC_ArrayLength); | 1114 Code* target = Builtins::builtin(Builtins::StoreIC_ArrayLength); |
| 1112 set_target(target); | 1115 set_target(target); |
| 1113 StubCache::Set(*name, HeapObject::cast(*object)->map(), target); | 1116 Isolate::Current()->stub_cache()->Set(*name, |
| 1117 HeapObject::cast(*object)->map(), |
| 1118 target); |
| 1114 return receiver->SetProperty(*name, *value, NONE); | 1119 return receiver->SetProperty(*name, *value, NONE); |
| 1115 } | 1120 } |
| 1116 | 1121 |
| 1117 // Lookup the property locally in the receiver. | 1122 // Lookup the property locally in the receiver. |
| 1118 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) { | 1123 if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) { |
| 1119 LookupResult lookup; | 1124 LookupResult lookup; |
| 1120 if (LookupForWrite(*receiver, *name, &lookup)) { | 1125 if (LookupForWrite(*receiver, *name, &lookup)) { |
| 1121 UpdateCaches(&lookup, state, receiver, name, value); | 1126 UpdateCaches(&lookup, state, receiver, name, value); |
| 1122 } | 1127 } |
| 1123 } | 1128 } |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 #undef ADDR | 1580 #undef ADDR |
| 1576 }; | 1581 }; |
| 1577 | 1582 |
| 1578 | 1583 |
| 1579 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 1584 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 1580 return IC_utilities[id]; | 1585 return IC_utilities[id]; |
| 1581 } | 1586 } |
| 1582 | 1587 |
| 1583 | 1588 |
| 1584 } } // namespace v8::internal | 1589 } } // namespace v8::internal |
| OLD | NEW |