Revision: 16845
Author: [email protected]
Date: Thu Sep 19 18:19:24 2013 UTC
Log: Optimize typed-array length loading.
[email protected]
Review URL: https://chromiumcodereview.appspot.com/23484060
http://code.google.com/p/v8/source/detail?r=16845
Modified:
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/hydrogen.h
/branches/bleeding_edge/src/ic.cc
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Thu Sep 19 17:02:57
2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Thu Sep 19 18:19:24
2013 UTC
@@ -5669,6 +5669,13 @@
FLAG_track_fields
? Representation::Smi() : Representation::Tagged());
}
+
+ static HObjectAccess ForTypedArrayLength() {
+ return HObjectAccess(
+ kInobject,
+ JSTypedArray::kLengthOffset,
+ Representation::Tagged());
+ }
static HObjectAccess ForAllocationSiteTransitionInfo() {
return HObjectAccess(kInobject, AllocationSite::kTransitionInfoOffset);
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Thu Sep 19 14:47:15 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen.cc Thu Sep 19 18:19:24 2013 UTC
@@ -4629,6 +4629,13 @@
}
return true;
}
+
+ if (IsTypedArrayLength()) {
+ for (int i = 1; i < types->length(); ++i) {
+ if (types->at(i)->instance_type() != JS_TYPED_ARRAY_TYPE) return
false;
+ }
+ return true;
+ }
for (int i = 1; i < types->length(); ++i) {
PropertyAccessInfo test_info(isolate(), types->at(i), name_);
@@ -4656,6 +4663,11 @@
checked_object, HObjectAccess::ForArrayLength(
info->map()->elements_kind()));
}
+
+ if (info->IsTypedArrayLength()) {
+ return New<HLoadNamedField>(
+ checked_object, HObjectAccess::ForTypedArrayLength());
+ }
HValue* checked_holder = checked_object;
if (info->has_holder()) {
=======================================
--- /branches/bleeding_edge/src/hydrogen.h Thu Sep 19 06:45:45 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen.h Thu Sep 19 18:19:24 2013 UTC
@@ -1981,6 +1981,11 @@
return map_->instance_type() == JS_ARRAY_TYPE &&
name_->Equals(isolate()->heap()->length_string());
}
+
+ bool IsTypedArrayLength() {
+ return map_->instance_type() == JS_TYPED_ARRAY_TYPE &&
+ name_->Equals(isolate()->heap()->length_string());
+ }
bool has_holder() { return !holder_.is_null(); }
=======================================
--- /branches/bleeding_edge/src/ic.cc Tue Sep 17 12:23:12 2013 UTC
+++ /branches/bleeding_edge/src/ic.cc Thu Sep 19 18:19:24 2013 UTC
@@ -1349,6 +1349,19 @@
return isolate()->stub_cache()->ComputeLoadNormal(name, receiver);
case CALLBACKS: {
Handle<Object> callback(lookup->GetCallbackObject(), isolate());
+ if (name->Equals(isolate()->heap()->length_string())) {
+ if (receiver->IsJSArray()) {
+ PropertyIndex lengthIndex = PropertyIndex::NewHeaderIndex(
+ JSArray::kLengthOffset / kPointerSize);
+ return isolate()->stub_cache()->ComputeLoadField(
+ name, receiver, receiver, lengthIndex,
Representation::Tagged());
+ } else if (receiver->IsJSTypedArray()) {
+ PropertyIndex lengthIndex = PropertyIndex::NewHeaderIndex(
+ JSTypedArray::kLengthOffset / kPointerSize);
+ return isolate()->stub_cache()->ComputeLoadField(
+ name, receiver, receiver, lengthIndex,
Representation::Tagged());
+ }
+ }
if (callback->IsExecutableAccessorInfo()) {
Handle<ExecutableAccessorInfo> info =
Handle<ExecutableAccessorInfo>::cast(callback);
@@ -1371,12 +1384,6 @@
}
return isolate()->stub_cache()->ComputeLoadViaGetter(
name, receiver, holder, function);
- } else if (receiver->IsJSArray() &&
- name->Equals(isolate()->heap()->length_string())) {
- PropertyIndex lengthIndex = PropertyIndex::NewHeaderIndex(
- JSArray::kLengthOffset / kPointerSize);
- return isolate()->stub_cache()->ComputeLoadField(
- name, receiver, holder, lengthIndex, Representation::Tagged());
}
// TODO(dcarney): Handle correctly.
if (callback->IsDeclaredAccessorInfo()) break;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.