Callers of ElementsAccessor::Validate() handlified.
R=yangguo@chromium.org Review URL: https://codereview.chromium.org/226153002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20532 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
448486ed48
commit
c9b0492bf5
@ -610,8 +610,9 @@ class ElementsAccessorBase : public ElementsAccessor {
|
||||
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 @@ class FastElementsAccessor
|
||||
if (!array->ShouldConvertToSlowElements(new_capacity)) {
|
||||
FastElementsAccessorSubclass::
|
||||
SetFastElementsCapacityAndLength(array, new_capacity, length);
|
||||
array->ValidateElements();
|
||||
JSObject::ValidateElements(array);
|
||||
return length_object;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class ElementsAccessor {
|
||||
|
||||
// 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
|
||||
|
@ -1379,6 +1379,15 @@ Handle<JSObject> Factory::NewJSObjectFromMap(
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
int length,
|
||||
int capacity,
|
||||
@ -1400,13 +1409,13 @@ Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements,
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -328,6 +328,11 @@ class Factory V8_FINAL {
|
||||
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 @@ class Factory V8_FINAL {
|
||||
INITIALIZE_ARRAY_ELEMENTS_WITH_HOLE, pretenure);
|
||||
}
|
||||
|
||||
// Allocate a JSArray with no elements
|
||||
Handle<JSArray> NewJSArrayWithElements(
|
||||
Handle<FixedArrayBase> elements,
|
||||
ElementsKind elements_kind,
|
||||
|
16
src/heap.cc
16
src/heap.cc
@ -4669,22 +4669,6 @@ MaybeObject* Heap::AllocateJSArrayStorage(
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
// Allocate map.
|
||||
// TODO(rossberg): Once we optimize proxies, think about a scheme to share
|
||||
|
@ -740,13 +740,6 @@ class Heap {
|
||||
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.
|
||||
|
@ -1496,11 +1496,11 @@ FixedArrayBase* JSObject::elements() {
|
||||
}
|
||||
|
||||
|
||||
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 @@ inline bool AllocationSite::DigestPretenuringFeedback() {
|
||||
|
||||
|
||||
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)) {
|
||||
|
@ -11232,7 +11232,7 @@ Handle<FixedArray> JSObject::SetFastElementsCapacityAndLength(
|
||||
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 @@ void JSObject::SetFastDoubleElementsCapacityAndLength(Handle<JSObject> object,
|
||||
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 @@ Handle<Object> JSObject::SetFastElement(Handle<JSObject> object,
|
||||
|
||||
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 @@ Handle<Object> JSObject::SetFastElement(Handle<JSObject> object,
|
||||
SetFastElementsCapacityAndLength(object, new_capacity, array_length,
|
||||
smi_mode);
|
||||
new_elements->set(index, *value);
|
||||
object->ValidateElements();
|
||||
JSObject::ValidateElements(object);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -12332,7 +12332,7 @@ Handle<Object> JSObject::SetDictionaryElement(Handle<JSObject> object,
|
||||
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 @@ Handle<Object> JSObject::SetFastDoubleElement(
|
||||
check_prototype);
|
||||
RETURN_IF_EMPTY_HANDLE_VALUE(object->GetIsolate(), result,
|
||||
Handle<Object>());
|
||||
object->ValidateElements();
|
||||
JSObject::ValidateElements(object);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -12424,7 +12424,7 @@ Handle<Object> JSObject::SetFastDoubleElement(
|
||||
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 @@ void JSObject::TransitionElementsKind(Handle<JSObject> object,
|
||||
if (IsFastSmiElementsKind(from_kind) &&
|
||||
IsFastDoubleElementsKind(to_kind)) {
|
||||
SetFastDoubleElementsCapacityAndLength(object, capacity, length);
|
||||
object->ValidateElements();
|
||||
JSObject::ValidateElements(object);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -12891,7 +12891,7 @@ void JSObject::TransitionElementsKind(Handle<JSObject> object,
|
||||
IsFastObjectElementsKind(to_kind)) {
|
||||
SetFastElementsCapacityAndLength(object, capacity, length,
|
||||
kDontAllowSmiElements);
|
||||
object->ValidateElements();
|
||||
JSObject::ValidateElements(object);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -14417,7 +14417,7 @@ Handle<Object> JSObject::PrepareElementsForSort(Handle<JSObject> object,
|
||||
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() ||
|
||||
|
@ -2423,7 +2423,7 @@ class JSObject: public JSReceiver {
|
||||
|
||||
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);
|
||||
|
@ -436,7 +436,7 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
|
||||
}
|
||||
}
|
||||
|
||||
object->ValidateElements();
|
||||
JSObject::ValidateElements(object);
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -5302,7 +5302,7 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
|
||||
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 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate,
|
||||
strict_mode,
|
||||
true,
|
||||
set_mode);
|
||||
js_object->ValidateElements();
|
||||
JSObject::ValidateElements(js_object);
|
||||
return result.is_null() ? result : value;
|
||||
}
|
||||
|
||||
@ -10658,8 +10658,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) {
|
||||
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 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) {
|
||||
JSObject::ResetElements(from);
|
||||
from->set_length(Smi::FromInt(0));
|
||||
|
||||
to->ValidateElements();
|
||||
JSObject::ValidateElements(to);
|
||||
return *to;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user