| Index: src/ic.cc
|
| ===================================================================
|
| --- src/ic.cc (revision 645)
|
| +++ src/ic.cc (working copy)
|
| @@ -453,20 +453,22 @@
|
| }
|
|
|
| if (FLAG_use_ic) {
|
| - // Use specialized code for getting the length of strings.
|
| - if (object->IsString() && name->Equals(Heap::length_symbol())) {
|
| + // Use specialized code for getting the length of strings and
|
| + // string wrapper objects. The length property of string wrapper
|
| + // objects is read-only and therefore always returns the length of
|
| + // the underlying string value. See ECMA-262 15.5.5.1.
|
| + if ((object->IsString() || object->IsStringWrapper()) &&
|
| + name->Equals(Heap::length_symbol())) {
|
| + HandleScope scope;
|
| + // Get the string if we have a string wrapper object.
|
| + if (object->IsJSValue()) {
|
| + object = Handle<Object>(Handle<JSValue>::cast(object)->value());
|
| + }
|
| #ifdef DEBUG
|
| if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n");
|
| #endif
|
| Code* target = NULL;
|
| - if (object->IsShortString()) {
|
| - target = Builtins::builtin(Builtins::LoadIC_ShortStringLength);
|
| - } else if (object->IsMediumString()) {
|
| - target = Builtins::builtin(Builtins::LoadIC_MediumStringLength);
|
| - } else {
|
| - ASSERT(object->IsLongString());
|
| - target = Builtins::builtin(Builtins::LoadIC_LongStringLength);
|
| - }
|
| + target = Builtins::builtin(Builtins::LoadIC_StringLength);
|
| set_target(target);
|
| StubCache::Set(*name, HeapObject::cast(*object)->map(), target);
|
| return Smi::FromInt(String::cast(*object)->length());
|
| @@ -637,15 +639,7 @@
|
| if (object->IsString() && name->Equals(Heap::length_symbol())) {
|
| Handle<String> string = Handle<String>::cast(object);
|
| Object* code = NULL;
|
| - if (string->IsShortString()) {
|
| - code = StubCache::ComputeKeyedLoadShortStringLength(*name, *string);
|
| - } else if (string->IsMediumString()) {
|
| - code =
|
| - StubCache::ComputeKeyedLoadMediumStringLength(*name, *string);
|
| - } else {
|
| - ASSERT(string->IsLongString());
|
| - code = StubCache::ComputeKeyedLoadLongStringLength(*name, *string);
|
| - }
|
| + code = StubCache::ComputeKeyedLoadStringLength(*name, *string);
|
| if (code->IsFailure()) return code;
|
| set_target(Code::cast(code));
|
| #ifdef DEBUG
|
|
|