Revision: 20532
Author: [email protected]
Date: Mon Apr 7 10:00:14 2014 UTC
Log: Callers of ElementsAccessor::Validate() handlified.
[email protected]
Review URL: https://codereview.chromium.org/226153002
http://code.google.com/p/v8/source/detail?r=20532
Modified:
/branches/bleeding_edge/src/elements.cc
/branches/bleeding_edge/src/elements.h
/branches/bleeding_edge/src/factory.cc
/branches/bleeding_edge/src/factory.h
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /branches/bleeding_edge/src/elements.cc Mon Apr 7 09:20:44 2014 UTC
+++ /branches/bleeding_edge/src/elements.cc Mon Apr 7 10:00:14 2014 UTC
@@ -610,8 +610,9 @@
ElementsAccessorSubclass::ValidateContents(holder, length);
}
- virtual void Validate(JSObject* holder) V8_FINAL V8_OVERRIDE {
- ElementsAccessorSubclass::ValidateImpl(holder);
+ virtual void Validate(Handle<JSObject> holder) V8_FINAL V8_OVERRIDE {
+ DisallowHeapAllocation no_gc;
+ ElementsAccessorSubclass::ValidateImpl(*holder);
}
static bool HasElementImpl(Object* receiver,
@@ -1011,7 +1012,7 @@
if (!array->ShouldConvertToSlowElements(new_capacity)) {
FastElementsAccessorSubclass::
SetFastElementsCapacityAndLength(array, new_capacity, length);
- array->ValidateElements();
+ JSObject::ValidateElements(array);
return length_object;
}
=======================================
--- /branches/bleeding_edge/src/elements.h Mon Apr 7 09:20:44 2014 UTC
+++ /branches/bleeding_edge/src/elements.h Mon Apr 7 10:00:14 2014 UTC
@@ -48,7 +48,7 @@
// Checks the elements of an object for consistency, asserting when a
problem
// is found.
- virtual void Validate(JSObject* obj) = 0;
+ virtual void Validate(Handle<JSObject> obj) = 0;
// Returns true if a holder contains an element with the specified key
// without iterating up the prototype chain. The caller can optionally
pass
=======================================
--- /branches/bleeding_edge/src/factory.cc Fri Apr 4 20:41:57 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc Mon Apr 7 10:00:14 2014 UTC
@@ -1377,6 +1377,15 @@
allocation_site.is_null() ? NULL : *allocation_site),
JSObject);
}
+
+
+Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind,
+ PretenureFlag pretenure) {
+ CALL_HEAP_FUNCTION(isolate(),
+ isolate()->heap()->AllocateJSArray(elements_kind,
+ pretenure),
+ JSArray);
+}
Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind,
@@ -1400,13 +1409,13 @@
int length,
PretenureFlag pretenure) {
ASSERT(length <= elements->length());
- CALL_HEAP_FUNCTION(
- isolate(),
- isolate()->heap()->AllocateJSArrayWithElements(*elements,
- elements_kind,
- length,
- pretenure),
- JSArray);
+ Handle<JSArray> array =
+ isolate()->factory()->NewJSArray(elements_kind, pretenure);
+
+ array->set_elements(*elements);
+ array->set_length(Smi::FromInt(length));
+ JSObject::ValidateElements(array);
+ return array;
}
=======================================
--- /branches/bleeding_edge/src/factory.h Fri Apr 4 20:41:57 2014 UTC
+++ /branches/bleeding_edge/src/factory.h Mon Apr 7 10:00:14 2014 UTC
@@ -328,6 +328,11 @@
Handle<ScopeInfo> scope_info);
// JS arrays are pretenured when allocated by the parser.
+
+ Handle<JSArray> NewJSArray(
+ ElementsKind elements_kind,
+ PretenureFlag pretenure = NOT_TENURED);
+
Handle<JSArray> NewJSArray(
ElementsKind elements_kind,
int length,
@@ -346,6 +351,7 @@
INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure);
}
+ // Allocate a JSArray with no elements
Handle<JSArray> NewJSArrayWithElements(
Handle<FixedArrayBase> elements,
ElementsKind elements_kind,
=======================================
--- /branches/bleeding_edge/src/heap.cc Mon Apr 7 09:41:13 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Mon Apr 7 10:00:14 2014 UTC
@@ -4667,22 +4667,6 @@
array->set_length(Smi::FromInt(length));
return array;
}
-
-
-MaybeObject* Heap::AllocateJSArrayWithElements(
- FixedArrayBase* elements,
- ElementsKind elements_kind,
- int length,
- PretenureFlag pretenure) {
- MaybeObject* maybe_array = AllocateJSArray(elements_kind, pretenure);
- JSArray* array;
- if (!maybe_array->To(&array)) return maybe_array;
-
- array->set_elements(elements);
- array->set_length(Smi::FromInt(length));
- array->ValidateElements();
- return array;
-}
MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) {
=======================================
--- /branches/bleeding_edge/src/heap.h Mon Apr 7 09:41:13 2014 UTC
+++ /branches/bleeding_edge/src/heap.h Mon Apr 7 10:00:14 2014 UTC
@@ -740,13 +740,6 @@
int capacity,
ArrayStorageAllocationMode mode = DONT_INITIALIZE_ARRAY_ELEMENTS);
- // Allocate a JSArray with no elements
- MUST_USE_RESULT MaybeObject* AllocateJSArrayWithElements(
- FixedArrayBase* array_base,
- ElementsKind elements_kind,
- int length,
- PretenureFlag pretenure = NOT_TENURED);
-
// Returns a deep copy of the JavaScript object.
// Properties and elements are copied too.
// Returns failure if allocation failed.
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Fri Apr 4 16:18:59 2014 UTC
+++ /branches/bleeding_edge/src/objects-inl.h Mon Apr 7 10:00:14 2014 UTC
@@ -1496,11 +1496,11 @@
}
-void JSObject::ValidateElements() {
+void JSObject::ValidateElements(Handle<JSObject> object) {
#ifdef ENABLE_SLOW_ASSERTS
if (FLAG_enable_slow_asserts) {
- ElementsAccessor* accessor = GetElementsAccessor();
- accessor->Validate(this);
+ ElementsAccessor* accessor = object->GetElementsAccessor();
+ accessor->Validate(object);
}
#endif
}
@@ -1640,7 +1640,7 @@
void JSObject::EnsureCanContainHeapObjectElements(Handle<JSObject> object)
{
- object->ValidateElements();
+ JSObject::ValidateElements(object);
ElementsKind elements_kind = object->map()->elements_kind();
if (!IsFastObjectElementsKind(elements_kind)) {
if (IsFastHoleyElementsKind(elements_kind)) {
=======================================
--- /branches/bleeding_edge/src/objects.cc Mon Apr 7 09:20:44 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Mon Apr 7 10:00:14 2014 UTC
@@ -11232,7 +11232,7 @@
Handle<Map> new_map = (new_elements_kind != elements_kind)
? GetElementsTransitionMap(object, new_elements_kind)
: handle(object->map());
- object->ValidateElements();
+ JSObject::ValidateElements(object);
JSObject::SetMapAndElements(object, new_map, new_elements);
// Transition through the allocation site as well if present.
@@ -11278,7 +11278,7 @@
ElementsAccessor* accessor =
ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS);
accessor->CopyElements(object, elems, elements_kind);
- object->ValidateElements();
+ JSObject::ValidateElements(object);
JSObject::SetMapAndElements(object, new_map, elems);
if (FLAG_trace_elements_transitions) {
@@ -12162,7 +12162,7 @@
SetFastDoubleElementsCapacityAndLength(object, new_capacity,
array_length);
FixedDoubleArray::cast(object->elements())->set(index,
value->Number());
- object->ValidateElements();
+ JSObject::ValidateElements(object);
return value;
}
// Change elements kind from Smi-only to generic FAST if necessary.
@@ -12186,7 +12186,7 @@
SetFastElementsCapacityAndLength(object, new_capacity,
array_length,
smi_mode);
new_elements->set(index, *value);
- object->ValidateElements();
+ JSObject::ValidateElements(object);
return value;
}
@@ -12332,7 +12332,7 @@
SetFastElementsCapacityAndLength(object, new_length, new_length,
smi_mode);
}
- object->ValidateElements();
+ JSObject::ValidateElements(object);
#ifdef DEBUG
if (FLAG_trace_normalization) {
PrintF("Object elements are fast case again:\n");
@@ -12384,7 +12384,7 @@
check_prototype);
RETURN_IF_EMPTY_HANDLE_VALUE(object->GetIsolate(), result,
Handle<Object>());
- object->ValidateElements();
+ JSObject::ValidateElements(object);
return result;
}
@@ -12424,7 +12424,7 @@
ASSERT(static_cast<uint32_t>(new_capacity) > index);
SetFastDoubleElementsCapacityAndLength(object, new_capacity, index +
1);
FixedDoubleArray::cast(object->elements())->set(index, double_value);
- object->ValidateElements();
+ JSObject::ValidateElements(object);
return value;
}
}
@@ -12883,7 +12883,7 @@
if (IsFastSmiElementsKind(from_kind) &&
IsFastDoubleElementsKind(to_kind)) {
SetFastDoubleElementsCapacityAndLength(object, capacity, length);
- object->ValidateElements();
+ JSObject::ValidateElements(object);
return;
}
@@ -12891,7 +12891,7 @@
IsFastObjectElementsKind(to_kind)) {
SetFastElementsCapacityAndLength(object, capacity, length,
kDontAllowSmiElements);
- object->ValidateElements();
+ JSObject::ValidateElements(object);
return;
}
@@ -14417,7 +14417,7 @@
Handle<FixedArray> fast_elements =
isolate->factory()->NewFixedArray(dict->NumberOfElements(),
tenure);
dict->CopyValuesTo(*fast_elements);
- object->ValidateElements();
+ JSObject::ValidateElements(object);
JSObject::SetMapAndElements(object, new_map, fast_elements);
} else if (object->HasExternalArrayElements() ||
=======================================
--- /branches/bleeding_edge/src/objects.h Mon Apr 7 09:20:44 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Mon Apr 7 10:00:14 2014 UTC
@@ -2423,7 +2423,7 @@
static void SetIdentityHash(Handle<JSObject> object, Handle<Smi> hash);
- inline void ValidateElements();
+ static inline void ValidateElements(Handle<JSObject> object);
// Makes sure that this object can contain HeapObject as elements.
static inline void EnsureCanContainHeapObjectElements(Handle<JSObject>
obj);
=======================================
--- /branches/bleeding_edge/src/runtime.cc Mon Apr 7 09:20:44 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Mon Apr 7 10:00:14 2014 UTC
@@ -436,7 +436,7 @@
}
}
- object->ValidateElements();
+ JSObject::ValidateElements(object);
return object;
}
@@ -5302,7 +5302,7 @@
return value;
}
- js_object->ValidateElements();
+ JSObject::ValidateElements(js_object);
if (js_object->HasExternalArrayElements() ||
js_object->HasFixedTypedArrayElements()) {
if (!value->IsNumber() && !value->IsUndefined()) {
@@ -5317,7 +5317,7 @@
strict_mode,
true,
set_mode);
- js_object->ValidateElements();
+ JSObject::ValidateElements(js_object);
return result.is_null() ? result : value;
}
@@ -10658,8 +10658,8 @@
ASSERT(args.length() == 2);
CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0);
CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1);
- from->ValidateElements();
- to->ValidateElements();
+ JSObject::ValidateElements(from);
+ JSObject::ValidateElements(to);
Handle<FixedArrayBase> new_elements(from->elements());
ElementsKind from_kind = from->GetElementsKind();
@@ -10670,7 +10670,7 @@
JSObject::ResetElements(from);
from->set_length(Smi::FromInt(0));
- to->ValidateElements();
+ JSObject::ValidateElements(to);
return *to;
}
--
--
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/d/optout.