Commit 8d3bd702 authored by yangguo@chromium.org's avatar yangguo@chromium.org

Handlify TransitionElements in runtime.cc.

R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/227113007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20551 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7f54e199
...@@ -331,18 +331,23 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate( ...@@ -331,18 +331,23 @@ MUST_USE_RESULT static MaybeHandle<Object> CreateObjectLiteralBoilerplate(
} }
MaybeObject* TransitionElements(Handle<Object> object, MUST_USE_RESULT static MaybeHandle<Object> TransitionElements(
ElementsKind to_kind, Handle<Object> object,
Isolate* isolate) { ElementsKind to_kind,
Isolate* isolate) {
HandleScope scope(isolate); HandleScope scope(isolate);
if (!object->IsJSObject()) return isolate->ThrowIllegalOperation(); if (!object->IsJSObject()) {
isolate->ThrowIllegalOperation();
return MaybeHandle<Object>();
}
ElementsKind from_kind = ElementsKind from_kind =
Handle<JSObject>::cast(object)->map()->elements_kind(); Handle<JSObject>::cast(object)->map()->elements_kind();
if (Map::IsValidElementsTransition(from_kind, to_kind)) { if (Map::IsValidElementsTransition(from_kind, to_kind)) {
JSObject::TransitionElementsKind(Handle<JSObject>::cast(object), to_kind); JSObject::TransitionElementsKind(Handle<JSObject>::cast(object), to_kind);
return *object; return object;
} }
return isolate->ThrowIllegalOperation(); isolate->ThrowIllegalOperation();
return MaybeHandle<Object>();
} }
...@@ -368,14 +373,14 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate( ...@@ -368,14 +373,14 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
Handle<FixedArrayBase> constant_elements_values( Handle<FixedArrayBase> constant_elements_values(
FixedArrayBase::cast(elements->get(1))); FixedArrayBase::cast(elements->get(1)));
ASSERT(IsFastElementsKind(constant_elements_kind)); { DisallowHeapAllocation no_gc;
Context* native_context = isolate->context()->native_context(); ASSERT(IsFastElementsKind(constant_elements_kind));
Object* maybe_maps_array = native_context->js_array_maps(); Context* native_context = isolate->context()->native_context();
ASSERT(!maybe_maps_array->IsUndefined()); Object* maps_array = native_context->js_array_maps();
Object* maybe_map = FixedArray::cast(maybe_maps_array)->get( ASSERT(!maps_array->IsUndefined());
constant_elements_kind); Object* map = FixedArray::cast(maps_array)->get(constant_elements_kind);
ASSERT(maybe_map->IsMap()); object->set_map(Map::cast(map));
object->set_map(Map::cast(maybe_map)); }
Handle<FixedArrayBase> copied_elements_values; Handle<FixedArrayBase> copied_elements_values;
if (IsFastDoubleElementsKind(constant_elements_kind)) { if (IsFastDoubleElementsKind(constant_elements_kind)) {
...@@ -403,8 +408,7 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate( ...@@ -403,8 +408,7 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
isolate->factory()->CopyFixedArray(fixed_array_values); isolate->factory()->CopyFixedArray(fixed_array_values);
copied_elements_values = fixed_array_values_copy; copied_elements_values = fixed_array_values_copy;
for (int i = 0; i < fixed_array_values->length(); i++) { for (int i = 0; i < fixed_array_values->length(); i++) {
Object* current = fixed_array_values->get(i); if (fixed_array_values->get(i)->IsFixedArray()) {
if (current->IsFixedArray()) {
// The value contains the constant_properties of a // The value contains the constant_properties of a
// simple object or array literal. // simple object or array literal.
Handle<FixedArray> fa(FixedArray::cast(fixed_array_values->get(i))); Handle<FixedArray> fa(FixedArray::cast(fixed_array_values->get(i)));
...@@ -428,10 +432,9 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate( ...@@ -428,10 +432,9 @@ MaybeHandle<Object> Runtime::CreateArrayLiteralBoilerplate(
ElementsKind elements_kind = object->GetElementsKind(); ElementsKind elements_kind = object->GetElementsKind();
if (!IsFastObjectElementsKind(elements_kind)) { if (!IsFastObjectElementsKind(elements_kind)) {
if (IsFastHoleyElementsKind(elements_kind)) { if (IsFastHoleyElementsKind(elements_kind)) {
CHECK(!TransitionElements(object, FAST_HOLEY_ELEMENTS, TransitionElements(object, FAST_HOLEY_ELEMENTS, isolate).Check();
isolate)->IsFailure());
} else { } else {
CHECK(!TransitionElements(object, FAST_ELEMENTS, isolate)->IsFailure()); TransitionElements(object, FAST_ELEMENTS, isolate).Check();
} }
} }
} }
...@@ -5076,17 +5079,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { ...@@ -5076,17 +5079,14 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) {
Handle<JSObject> js_object(args.at<JSObject>(0)); Handle<JSObject> js_object(args.at<JSObject>(0));
ElementsKind elements_kind = js_object->GetElementsKind(); ElementsKind elements_kind = js_object->GetElementsKind();
if (IsFastDoubleElementsKind(elements_kind)) { if (IsFastDoubleElementsKind(elements_kind)) {
FixedArrayBase* elements = js_object->elements(); if (args.at<Smi>(1)->value() >= js_object->elements()->length()) {
if (args.at<Smi>(1)->value() >= elements->length()) {
if (IsFastHoleyElementsKind(elements_kind)) { if (IsFastHoleyElementsKind(elements_kind)) {
elements_kind = FAST_HOLEY_ELEMENTS; elements_kind = FAST_HOLEY_ELEMENTS;
} else { } else {
elements_kind = FAST_ELEMENTS; elements_kind = FAST_ELEMENTS;
} }
MaybeObject* maybe_object = TransitionElements(js_object, RETURN_FAILURE_ON_EXCEPTION(
elements_kind, isolate, TransitionElements(js_object, elements_kind, isolate));
isolate);
if (maybe_object->IsFailure()) return maybe_object;
} }
} else { } else {
ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) || ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment