Index: src/ic.cc |
=================================================================== |
--- src/ic.cc (revision 3095) |
+++ src/ic.cc (working copy) |
@@ -265,6 +265,55 @@ |
} |
+Code* KeyedLoadIC::external_array_stub(JSObject::ElementsKind elements_kind) { |
+ switch (elements_kind) { |
+ case JSObject::EXTERNAL_BYTE_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedLoadIC_ExternalByteArray); |
+ case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedLoadIC_ExternalUnsignedByteArray); |
+ case JSObject::EXTERNAL_SHORT_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedLoadIC_ExternalShortArray); |
+ case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
+ return Builtins::builtin( |
+ Builtins::KeyedLoadIC_ExternalUnsignedShortArray); |
+ case JSObject::EXTERNAL_INT_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedLoadIC_ExternalIntArray); |
+ case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedLoadIC_ExternalUnsignedIntArray); |
+ case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedLoadIC_ExternalFloatArray); |
+ default: |
+ UNREACHABLE(); |
+ return NULL; |
+ } |
+} |
+ |
+ |
+Code* KeyedStoreIC::external_array_stub(JSObject::ElementsKind elements_kind) { |
+ switch (elements_kind) { |
+ case JSObject::EXTERNAL_BYTE_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedStoreIC_ExternalByteArray); |
+ case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
+ return Builtins::builtin( |
+ Builtins::KeyedStoreIC_ExternalUnsignedByteArray); |
+ case JSObject::EXTERNAL_SHORT_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedStoreIC_ExternalShortArray); |
+ case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
+ return Builtins::builtin( |
+ Builtins::KeyedStoreIC_ExternalUnsignedShortArray); |
+ case JSObject::EXTERNAL_INT_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedStoreIC_ExternalIntArray); |
+ case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedStoreIC_ExternalUnsignedIntArray); |
+ case JSObject::EXTERNAL_FLOAT_ELEMENTS: |
+ return Builtins::builtin(Builtins::KeyedStoreIC_ExternalFloatArray); |
+ default: |
+ UNREACHABLE(); |
+ return NULL; |
+ } |
+} |
+ |
+ |
static bool HasInterceptorGetter(JSObject* object) { |
return !object->GetNamedInterceptor()->getter()->IsUndefined(); |
} |
@@ -823,7 +872,14 @@ |
bool use_ic = FLAG_use_ic && !object->IsAccessCheckNeeded(); |
if (use_ic) { |
- set_target(generic_stub()); |
+ Code* stub = generic_stub(); |
+ if (object->IsJSObject()) { |
+ Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
+ if (receiver->HasExternalArrayElements()) { |
+ stub = external_array_stub(receiver->GetElementsKind()); |
+ } |
+ } |
+ set_target(stub); |
// For JSObjects that are not value wrappers and that do not have |
// indexed interceptors, we initialize the inlined fast case (if |
// present) by patching the inlined map check. |
@@ -1110,7 +1166,16 @@ |
bool use_ic = FLAG_use_ic && !object->IsAccessCheckNeeded(); |
ASSERT(!(use_ic && object->IsJSGlobalProxy())); |
- if (use_ic) set_target(generic_stub()); |
+ if (use_ic) { |
+ Code* stub = generic_stub(); |
+ if (object->IsJSObject()) { |
+ Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
+ if (receiver->HasExternalArrayElements()) { |
+ stub = external_array_stub(receiver->GetElementsKind()); |
+ } |
+ } |
+ set_target(stub); |
+ } |
// Set the property. |
return Runtime::SetObjectProperty(object, key, value, NONE); |