summaryrefslogtreecommitdiffstats
path: root/V8Binding/v8/src/objects-inl.h
diff options
context:
space:
mode:
Diffstat (limited to 'V8Binding/v8/src/objects-inl.h')
-rw-r--r--V8Binding/v8/src/objects-inl.h121
1 files changed, 100 insertions, 21 deletions
diff --git a/V8Binding/v8/src/objects-inl.h b/V8Binding/v8/src/objects-inl.h
index 7abc7c3..a3bd3ce 100644
--- a/V8Binding/v8/src/objects-inl.h
+++ b/V8Binding/v8/src/objects-inl.h
@@ -100,6 +100,25 @@ PropertyDetails PropertyDetails::AsDeleted() {
}
+bool Object::IsInstanceOf(FunctionTemplateInfo* expected) {
+ // There is a constraint on the object; check.
+ if (!this->IsJSObject()) return false;
+ // Fetch the constructor function of the object.
+ Object* cons_obj = JSObject::cast(this)->map()->constructor();
+ if (!cons_obj->IsJSFunction()) return false;
+ JSFunction* fun = JSFunction::cast(cons_obj);
+ // Iterate through the chain of inheriting function templates to
+ // see if the required one occurs.
+ for (Object* type = fun->shared()->function_data();
+ type->IsFunctionTemplateInfo();
+ type = FunctionTemplateInfo::cast(type)->parent_template()) {
+ if (type == expected) return true;
+ }
+ // Didn't find the required type in the inheritance chain.
+ return false;
+}
+
+
bool Object::IsSmi() {
return HAS_SMI_TAG(this);
}
@@ -321,6 +340,12 @@ bool Object::IsByteArray() {
}
+bool Object::IsPixelArray() {
+ return Object::IsHeapObject() &&
+ HeapObject::cast(this)->map()->instance_type() == PIXEL_ARRAY_TYPE;
+}
+
+
bool Object::IsFailure() {
return HAS_FAILURE_TAG(this);
}
@@ -1043,7 +1068,22 @@ void HeapNumber::set_value(double value) {
ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset)
-ACCESSORS(JSObject, elements, FixedArray, kElementsOffset)
+
+
+Array* JSObject::elements() {
+ Object* array = READ_FIELD(this, kElementsOffset);
+ // In the assert below Dictionary is covered under FixedArray.
+ ASSERT(array->IsFixedArray() || array->IsPixelArray());
+ return reinterpret_cast<Array*>(array);
+}
+
+
+void JSObject::set_elements(Array* value, WriteBarrierMode mode) {
+ // In the assert below Dictionary is covered under FixedArray.
+ ASSERT(value->IsFixedArray() || value->IsPixelArray());
+ WRITE_FIELD(this, kElementsOffset, value);
+ CONDITIONAL_WRITE_BARRIER(this, kElementsOffset, mode);
+}
void JSObject::initialize_properties() {
@@ -1502,6 +1542,7 @@ CAST_ACCESSOR(JSArray)
CAST_ACCESSOR(JSRegExp)
CAST_ACCESSOR(Proxy)
CAST_ACCESSOR(ByteArray)
+CAST_ACCESSOR(PixelArray)
CAST_ACCESSOR(Struct)
@@ -1860,6 +1901,32 @@ Address ByteArray::GetDataStartAddress() {
}
+uint8_t* PixelArray::external_pointer() {
+ intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset);
+ return reinterpret_cast<uint8_t*>(ptr);
+}
+
+
+void PixelArray::set_external_pointer(uint8_t* value, WriteBarrierMode mode) {
+ intptr_t ptr = reinterpret_cast<intptr_t>(value);
+ WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr);
+}
+
+
+uint8_t PixelArray::get(int index) {
+ ASSERT((index >= 0) && (index < this->length()));
+ uint8_t* ptr = external_pointer();
+ return ptr[index];
+}
+
+
+void PixelArray::set(int index, uint8_t value) {
+ ASSERT((index >= 0) && (index < this->length()));
+ uint8_t* ptr = external_pointer();
+ ptr[index] = value;
+}
+
+
int Map::instance_size() {
return READ_BYTE_FIELD(this, kInstanceSizeOffset) << kPointerSizeLog2;
}
@@ -2293,6 +2360,11 @@ bool JSFunction::IsBoilerplate() {
}
+bool JSFunction::IsBuiltin() {
+ return context()->global()->IsJSBuiltinsObject();
+}
+
+
bool JSObject::IsLoaded() {
return !map()->needs_loading();
}
@@ -2523,8 +2595,33 @@ void JSRegExp::SetDataAt(int index, Object* value) {
}
+JSObject::ElementsKind JSObject::GetElementsKind() {
+ Array* array = elements();
+ if (array->IsFixedArray()) {
+ // FAST_ELEMENTS or DICTIONARY_ELEMENTS are both stored in a FixedArray.
+ if (array->map() == Heap::fixed_array_map()) {
+ return FAST_ELEMENTS;
+ }
+ ASSERT(array->IsDictionary());
+ return DICTIONARY_ELEMENTS;
+ }
+ ASSERT(array->IsPixelArray());
+ return PIXEL_ELEMENTS;
+}
+
+
bool JSObject::HasFastElements() {
- return !elements()->IsDictionary();
+ return GetElementsKind() == FAST_ELEMENTS;
+}
+
+
+bool JSObject::HasDictionaryElements() {
+ return GetElementsKind() == DICTIONARY_ELEMENTS;
+}
+
+
+bool JSObject::HasPixelElements() {
+ return GetElementsKind() == PIXEL_ELEMENTS;
}
@@ -2545,7 +2642,7 @@ StringDictionary* JSObject::property_dictionary() {
NumberDictionary* JSObject::element_dictionary() {
- ASSERT(!HasFastElements());
+ ASSERT(HasDictionaryElements());
return NumberDictionary::cast(elements());
}
@@ -2651,24 +2748,6 @@ bool JSObject::HasElement(uint32_t index) {
}
-Smi* JSObject::InterceptorPropertyLookupHint(String* name) {
- // TODO(antonm): Do we want to do any shortcuts for global object?
- if (HasFastProperties()) {
- LookupResult lookup;
- LocalLookupRealNamedProperty(name, &lookup);
- if (lookup.IsValid()) {
- if (lookup.type() == FIELD && lookup.IsCacheable()) {
- return Smi::FromInt(lookup.GetFieldIndex());
- }
- } else {
- return Smi::FromInt(kLookupInPrototype);
- }
- }
-
- return Smi::FromInt(kLookupInHolder);
-}
-
-
bool AccessorInfo::all_can_read() {
return BooleanBit::get(flag(), kAllCanReadBit);
}