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

Unified Diff: src/objects-inl.h

Issue 227713003: Further ElementsAccessor handlification (Get(), AddElementsToFixedArray() and HasElement()). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing review notes Created 6 years, 8 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
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 3939921bf7304378b13540fc4a1fda3f426216b3..72c8b1172fc2a7367d3985d39fd785e65eb09fc7 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -2175,6 +2175,11 @@ Object* FixedArray::get(int index) {
}
+Handle<Object> FixedArray::get(Handle<FixedArray> array, int index) {
+ return handle(array->get(index), array->GetIsolate());
+}
+
+
bool FixedArray::is_the_hole(int index) {
return get(index) == GetHeap()->the_hole_value();
}
@@ -2240,11 +2245,12 @@ MaybeObject* FixedDoubleArray::get(int index) {
}
-Handle<Object> FixedDoubleArray::get_as_handle(int index) {
- if (is_the_hole(index)) {
- return GetIsolate()->factory()->the_hole_value();
+Handle<Object> FixedDoubleArray::get(Handle<FixedDoubleArray> array,
+ int index) {
+ if (array->is_the_hole(index)) {
+ return array->GetIsolate()->factory()->the_hole_value();
} else {
- return GetIsolate()->factory()->NewNumber(get_scalar(index));
+ return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index));
}
}
@@ -3575,11 +3581,18 @@ uint8_t ExternalUint8ClampedArray::get_scalar(int index) {
}
-MaybeObject* ExternalUint8ClampedArray::get(int index) {
+Object* ExternalUint8ClampedArray::get(int index) {
return Smi::FromInt(static_cast<int>(get_scalar(index)));
}
+Handle<Object> ExternalUint8ClampedArray::get(
+ Handle<ExternalUint8ClampedArray> array,
+ int index) {
+ return handle(array->get(index), array->GetIsolate());
+}
+
+
void ExternalUint8ClampedArray::set(int index, uint8_t value) {
ASSERT((index >= 0) && (index < this->length()));
uint8_t* ptr = external_uint8_clamped_pointer();
@@ -3606,11 +3619,17 @@ int8_t ExternalInt8Array::get_scalar(int index) {
}
-MaybeObject* ExternalInt8Array::get(int index) {
+Object* ExternalInt8Array::get(int index) {
return Smi::FromInt(static_cast<int>(get_scalar(index)));
}
+Handle<Object> ExternalInt8Array::get(Handle<ExternalInt8Array> array,
+ int index) {
+ return handle(array->get(index), array->GetIsolate());
+}
+
+
void ExternalInt8Array::set(int index, int8_t value) {
ASSERT((index >= 0) && (index < this->length()));
int8_t* ptr = static_cast<int8_t*>(external_pointer());
@@ -3625,11 +3644,17 @@ uint8_t ExternalUint8Array::get_scalar(int index) {
}
-MaybeObject* ExternalUint8Array::get(int index) {
+Object* ExternalUint8Array::get(int index) {
return Smi::FromInt(static_cast<int>(get_scalar(index)));
}
+Handle<Object> ExternalUint8Array::get(Handle<ExternalUint8Array> array,
+ int index) {
+ return handle(array->get(index), array->GetIsolate());
+}
+
+
void ExternalUint8Array::set(int index, uint8_t value) {
ASSERT((index >= 0) && (index < this->length()));
uint8_t* ptr = static_cast<uint8_t*>(external_pointer());
@@ -3644,11 +3669,17 @@ int16_t ExternalInt16Array::get_scalar(int index) {
}
-MaybeObject* ExternalInt16Array::get(int index) {
+Object* ExternalInt16Array::get(int index) {
return Smi::FromInt(static_cast<int>(get_scalar(index)));
}
+Handle<Object> ExternalInt16Array::get(Handle<ExternalInt16Array> array,
+ int index) {
+ return handle(array->get(index), array->GetIsolate());
+}
+
+
void ExternalInt16Array::set(int index, int16_t value) {
ASSERT((index >= 0) && (index < this->length()));
int16_t* ptr = static_cast<int16_t*>(external_pointer());
@@ -3663,11 +3694,17 @@ uint16_t ExternalUint16Array::get_scalar(int index) {
}
-MaybeObject* ExternalUint16Array::get(int index) {
+Object* ExternalUint16Array::get(int index) {
return Smi::FromInt(static_cast<int>(get_scalar(index)));
}
+Handle<Object> ExternalUint16Array::get(Handle<ExternalUint16Array> array,
+ int index) {
+ return handle(array->get(index), array->GetIsolate());
+}
+
+
void ExternalUint16Array::set(int index, uint16_t value) {
ASSERT((index >= 0) && (index < this->length()));
uint16_t* ptr = static_cast<uint16_t*>(external_pointer());
@@ -3683,7 +3720,14 @@ int32_t ExternalInt32Array::get_scalar(int index) {
MaybeObject* ExternalInt32Array::get(int index) {
- return GetHeap()->NumberFromInt32(get_scalar(index));
+ return GetHeap()->NumberFromInt32(get_scalar(index));
+}
+
+
+Handle<Object> ExternalInt32Array::get(Handle<ExternalInt32Array> array,
+ int index) {
+ return array->GetIsolate()->factory()->
+ NewNumberFromInt(array->get_scalar(index));
}
@@ -3702,7 +3746,14 @@ uint32_t ExternalUint32Array::get_scalar(int index) {
MaybeObject* ExternalUint32Array::get(int index) {
- return GetHeap()->NumberFromUint32(get_scalar(index));
+ return GetHeap()->NumberFromUint32(get_scalar(index));
+}
+
+
+Handle<Object> ExternalUint32Array::get(Handle<ExternalUint32Array> array,
+ int index) {
+ return array->GetIsolate()->factory()->
+ NewNumberFromUint(array->get_scalar(index));
}
@@ -3721,7 +3772,13 @@ float ExternalFloat32Array::get_scalar(int index) {
MaybeObject* ExternalFloat32Array::get(int index) {
- return GetHeap()->NumberFromDouble(get_scalar(index));
+ return GetHeap()->NumberFromDouble(get_scalar(index));
+}
+
+
+Handle<Object> ExternalFloat32Array::get(Handle<ExternalFloat32Array> array,
+ int index) {
+ return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index));
}
@@ -3744,6 +3801,12 @@ MaybeObject* ExternalFloat64Array::get(int index) {
}
+Handle<Object> ExternalFloat64Array::get(Handle<ExternalFloat64Array> array,
+ int index) {
+ return array->GetIsolate()->factory()->NewNumber(array->get_scalar(index));
+}
+
+
void ExternalFloat64Array::set(int index, double value) {
ASSERT((index >= 0) && (index < this->length()));
double* ptr = static_cast<double*>(external_pointer());
@@ -3890,6 +3953,13 @@ MaybeObject* FixedTypedArray<Traits>::get(int index) {
}
template <class Traits>
+Handle<Object> FixedTypedArray<Traits>::get(
+ Handle<FixedTypedArray<Traits> > array,
+ int index) {
+ return Traits::ToHandle(array->GetIsolate(), array->get_scalar(index));
+}
+
+template <class Traits>
MaybeObject* FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) {
ElementType cast_value = Traits::defaultValue();
if (index < static_cast<uint32_t>(length())) {
@@ -3925,46 +3995,92 @@ MaybeObject* Uint8ArrayTraits::ToObject(Heap*, uint8_t scalar) {
}
+Handle<Object> Uint8ArrayTraits::ToHandle(Isolate* isolate, uint8_t scalar) {
+ return handle(Smi::FromInt(scalar), isolate);
+}
+
+
MaybeObject* Uint8ClampedArrayTraits::ToObject(Heap*, uint8_t scalar) {
return Smi::FromInt(scalar);
}
+Handle<Object> Uint8ClampedArrayTraits::ToHandle(Isolate* isolate,
+ uint8_t scalar) {
+ return handle(Smi::FromInt(scalar), isolate);
+}
+
+
MaybeObject* Int8ArrayTraits::ToObject(Heap*, int8_t scalar) {
return Smi::FromInt(scalar);
}
+Handle<Object> Int8ArrayTraits::ToHandle(Isolate* isolate, int8_t scalar) {
+ return handle(Smi::FromInt(scalar), isolate);
+}
+
+
MaybeObject* Uint16ArrayTraits::ToObject(Heap*, uint16_t scalar) {
return Smi::FromInt(scalar);
}
+Handle<Object> Uint16ArrayTraits::ToHandle(Isolate* isolate, uint16_t scalar) {
+ return handle(Smi::FromInt(scalar), isolate);
+}
+
+
MaybeObject* Int16ArrayTraits::ToObject(Heap*, int16_t scalar) {
return Smi::FromInt(scalar);
}
+Handle<Object> Int16ArrayTraits::ToHandle(Isolate* isolate, int16_t scalar) {
+ return handle(Smi::FromInt(scalar), isolate);
+}
+
+
MaybeObject* Uint32ArrayTraits::ToObject(Heap* heap, uint32_t scalar) {
return heap->NumberFromUint32(scalar);
}
+Handle<Object> Uint32ArrayTraits::ToHandle(Isolate* isolate, uint32_t scalar) {
+ return isolate->factory()->NewNumberFromUint(scalar);
+}
+
+
MaybeObject* Int32ArrayTraits::ToObject(Heap* heap, int32_t scalar) {
return heap->NumberFromInt32(scalar);
}
+Handle<Object> Int32ArrayTraits::ToHandle(Isolate* isolate, int32_t scalar) {
+ return isolate->factory()->NewNumberFromInt(scalar);
+}
+
+
MaybeObject* Float32ArrayTraits::ToObject(Heap* heap, float scalar) {
return heap->NumberFromDouble(scalar);
}
+Handle<Object> Float32ArrayTraits::ToHandle(Isolate* isolate, float scalar) {
+ return isolate->factory()->NewNumber(scalar);
+}
+
+
MaybeObject* Float64ArrayTraits::ToObject(Heap* heap, double scalar) {
return heap->NumberFromDouble(scalar);
}
+Handle<Object> Float64ArrayTraits::ToHandle(Isolate* isolate, double scalar) {
+ return isolate->factory()->NewNumber(scalar);
+}
+
+
int Map::visitor_id() {
return READ_BYTE_FIELD(this, kVisitorIdOffset);
}
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698