Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: src/objects-inl.h

Issue 1159433003: Use GetProperty for getting elements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index a5b6811cb50d7500ac2d2c31c63e557752d90a41..cc8ce3492e51d93b477c34860a65f774ca06906d 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1168,11 +1168,8 @@ MaybeHandle<Object> Object::GetProperty(Handle<Object> object,
MaybeHandle<Object> Object::GetElement(Isolate* isolate,
Handle<Object> object,
uint32_t index) {
- // GetElement can trigger a getter which can cause allocation.
- // This was not always the case. This DCHECK is here to catch
- // leftover incorrect uses.
- DCHECK(AllowHeapAllocation::IsAllowed());
- return Object::GetElementWithReceiver(isolate, object, object, index);
+ LookupIterator it(isolate, object, index);
+ return GetProperty(&it);
}
@@ -1211,14 +1208,6 @@ MaybeHandle<Object> Object::GetProperty(Isolate* isolate,
}
-MaybeHandle<Object> JSProxy::GetElementWithHandler(Handle<JSProxy> proxy,
- Handle<Object> receiver,
- uint32_t index) {
- return GetPropertyWithHandler(
- proxy, receiver, proxy->GetIsolate()->factory()->Uint32ToString(index));
-}
-
-
MaybeHandle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
uint32_t index,
@@ -2225,7 +2214,7 @@ void Struct::InitializeBody(int object_size) {
}
-bool Object::ToArrayIndex(uint32_t* index) {
+bool Object::ToArrayLength(uint32_t* index) {
if (IsSmi()) {
int value = Smi::cast(this)->value();
if (value < 0) return false;
@@ -2244,6 +2233,11 @@ bool Object::ToArrayIndex(uint32_t* index) {
}
+bool Object::ToArrayIndex(uint32_t* index) {
+ return ToArrayLength(index) && *index != kMaxUInt32;
+}
+
+
bool Object::IsStringObjectWithCharacterAt(uint32_t index) {
if (!this->IsJSValue()) return false;
@@ -6525,6 +6519,14 @@ Object* JSTypedArray::length() const {
}
+uint32_t JSTypedArray::length_value() const {
+ if (WasNeutered()) return 0;
+ uint32_t index;
+ CHECK(Object::cast(READ_FIELD(this, kLengthOffset))->ToArrayIndex(&index));
Igor Sheludko 2015/05/26 17:11:56 ToArrayLength()?
+ return index;
+}
+
+
void JSTypedArray::set_length(Object* value, WriteBarrierMode mode) {
WRITE_FIELD(this, kLengthOffset, value);
CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kLengthOffset, value, mode);
@@ -6828,7 +6830,7 @@ bool StringHasher::UpdateIndex(uint16_t c) {
return false;
}
}
- if (array_index_ > 429496729U - ((d + 2) >> 3)) {
+ if (array_index_ > 429496729U - ((d + 3) >> 3)) {
is_array_index_ = false;
return false;
}
« src/elements.cc ('K') | « src/objects.cc ('k') | src/runtime/runtime-array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698