| 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 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 if ((object->IsString() || object->IsStringWrapper()) && | 589 if ((object->IsString() || object->IsStringWrapper()) && |
| 590 name->Equals(Heap::length_symbol())) { | 590 name->Equals(Heap::length_symbol())) { |
| 591 HandleScope scope; | 591 HandleScope scope; |
| 592 // Get the string if we have a string wrapper object. | 592 // Get the string if we have a string wrapper object. |
| 593 if (object->IsJSValue()) { | 593 if (object->IsJSValue()) { |
| 594 object = Handle<Object>(Handle<JSValue>::cast(object)->value()); | 594 object = Handle<Object>(Handle<JSValue>::cast(object)->value()); |
| 595 } | 595 } |
| 596 #ifdef DEBUG | 596 #ifdef DEBUG |
| 597 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); | 597 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n"); |
| 598 #endif | 598 #endif |
| 599 Map* map = HeapObject::cast(*object)->map(); |
| 600 if (object->IsString()) { |
| 601 const int offset = String::kLengthOffset; |
| 602 PatchInlinedLoad(address(), map, offset); |
| 603 } |
| 604 |
| 599 Code* target = NULL; | 605 Code* target = NULL; |
| 600 target = Builtins::builtin(Builtins::LoadIC_StringLength); | 606 target = Builtins::builtin(Builtins::LoadIC_StringLength); |
| 601 set_target(target); | 607 set_target(target); |
| 602 StubCache::Set(*name, HeapObject::cast(*object)->map(), target); | 608 StubCache::Set(*name, map, target); |
| 603 return Smi::FromInt(String::cast(*object)->length()); | 609 return Smi::FromInt(String::cast(*object)->length()); |
| 604 } | 610 } |
| 605 | 611 |
| 606 // Use specialized code for getting the length of arrays. | 612 // Use specialized code for getting the length of arrays. |
| 607 if (object->IsJSArray() && name->Equals(Heap::length_symbol())) { | 613 if (object->IsJSArray() && name->Equals(Heap::length_symbol())) { |
| 608 #ifdef DEBUG | 614 #ifdef DEBUG |
| 609 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); | 615 if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); |
| 610 #endif | 616 #endif |
| 617 Map* map = HeapObject::cast(*object)->map(); |
| 618 const int offset = JSArray::kLengthOffset; |
| 619 PatchInlinedLoad(address(), map, offset); |
| 620 |
| 611 Code* target = Builtins::builtin(Builtins::LoadIC_ArrayLength); | 621 Code* target = Builtins::builtin(Builtins::LoadIC_ArrayLength); |
| 612 set_target(target); | 622 set_target(target); |
| 613 StubCache::Set(*name, HeapObject::cast(*object)->map(), target); | 623 StubCache::Set(*name, map, target); |
| 614 return JSArray::cast(*object)->length(); | 624 return JSArray::cast(*object)->length(); |
| 615 } | 625 } |
| 616 | 626 |
| 617 // Use specialized code for getting prototype of functions. | 627 // Use specialized code for getting prototype of functions. |
| 618 if (object->IsJSFunction() && name->Equals(Heap::prototype_symbol()) && | 628 if (object->IsJSFunction() && name->Equals(Heap::prototype_symbol()) && |
| 619 JSFunction::cast(*object)->should_have_prototype()) { | 629 JSFunction::cast(*object)->should_have_prototype()) { |
| 620 #ifdef DEBUG | 630 #ifdef DEBUG |
| 621 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); | 631 if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); |
| 622 #endif | 632 #endif |
| 623 Code* target = Builtins::builtin(Builtins::LoadIC_FunctionPrototype); | 633 Code* target = Builtins::builtin(Builtins::LoadIC_FunctionPrototype); |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 #undef ADDR | 1510 #undef ADDR |
| 1501 }; | 1511 }; |
| 1502 | 1512 |
| 1503 | 1513 |
| 1504 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 1514 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 1505 return IC_utilities[id]; | 1515 return IC_utilities[id]; |
| 1506 } | 1516 } |
| 1507 | 1517 |
| 1508 | 1518 |
| 1509 } } // namespace v8::internal | 1519 } } // namespace v8::internal |
| OLD | NEW |