Index: src/ic.cc |
diff --git a/src/ic.cc b/src/ic.cc |
index 1418f02fbe889bcb5c5c935b4599b4d8a57742d3..386941ae0b090c7e577aa3241f69982e9b8f6fbc 100644 |
--- a/src/ic.cc |
+++ b/src/ic.cc |
@@ -852,26 +852,6 @@ MaybeObject* LoadIC::Load(State state, |
return Smi::FromInt(String::cast(*string)->length()); |
} |
- // Use specialized code for getting the length of arrays. |
- if (object->IsJSArray() && |
- name->Equals(isolate()->heap()->length_symbol())) { |
- Handle<Code> stub; |
- if (state == UNINITIALIZED) { |
- stub = pre_monomorphic_stub(); |
- } else if (state == PREMONOMORPHIC) { |
- stub = isolate()->builtins()->LoadIC_ArrayLength(); |
- } else if (state != MEGAMORPHIC) { |
- stub = megamorphic_stub(); |
- } |
- if (!stub.is_null()) { |
- set_target(*stub); |
-#ifdef DEBUG |
- if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n"); |
-#endif |
- } |
- return JSArray::cast(*object)->length(); |
- } |
- |
// Use specialized code for getting prototype of functions. |
if (object->IsJSFunction() && |
name->Equals(isolate()->heap()->prototype_symbol()) && |
@@ -1004,9 +984,18 @@ void LoadIC::UpdateCaches(LookupResult* lookup, |
code = isolate()->stub_cache()->ComputeLoadViaGetter( |
name, receiver, holder, Handle<JSFunction>::cast(getter)); |
} else { |
- ASSERT(callback->IsForeign()); |
- // No IC support for old-style native accessors. |
- return; |
+ // we have IC support only for getting the array length property. |
Jakob Kummerow
2012/11/16 12:57:10
nit: capital W
Massi
2012/11/19 12:26:15
Done.
|
+ if (holder->IsJSArray() && |
Jakob Kummerow
2012/11/16 12:57:10
nit: You can avoid one level of indentation here b
Massi
2012/11/19 12:26:15
Done.
|
+ name->Equals(isolate()->heap()->length_symbol())) { |
+ ASSERT(reinterpret_cast<AccessorDescriptor*>( |
+ Handle<Foreign>::cast(callback)->foreign_address()) |
+ == &Accessors::ArrayLength); |
+ // Note that the resulting code object is marked as "Code::FIELD" |
+ // and not as "Code::CALLBACKS". |
+ code = isolate()->stub_cache()->ComputeLoadField( |
+ name, receiver, holder, JSArray::ArrayLengthIndex()); |
+ } |
+ if (code.is_null()) return; |
} |
break; |
} |