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

Unified Diff: src/runtime.cc

Issue 4100005: Version 2.5.2 (Closed)
Patch Set: Created 10 years, 2 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/runtime.h ('k') | src/serialize.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 9a604a035dc9ed8662c62494cca75ad38e2e0494..f701c031132305ebbb62aab1487096a91fc3b060 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -99,12 +99,14 @@ namespace internal {
static StaticResource<StringInputBuffer> runtime_string_input_buffer;
-MUST_USE_RESULT static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
+MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(JSObject* boilerplate) {
StackLimitCheck check;
if (check.HasOverflowed()) return Top::StackOverflow();
- Object* result = Heap::CopyJSObject(boilerplate);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result = Heap::CopyJSObject(boilerplate);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
JSObject* copy = JSObject::cast(result);
// Deep copy local properties.
@@ -114,8 +116,9 @@ MUST_USE_RESULT static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
Object* value = properties->get(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(js_object);
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
properties->set(i, result);
}
}
@@ -124,14 +127,17 @@ MUST_USE_RESULT static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
Object* value = copy->InObjectPropertyAt(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(js_object);
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
copy->InObjectPropertyAtPut(i, result);
}
}
} else {
- result = Heap::AllocateFixedArray(copy->NumberOfLocalProperties(NONE));
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result =
+ Heap::AllocateFixedArray(copy->NumberOfLocalProperties(NONE));
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
FixedArray* names = FixedArray::cast(result);
copy->GetLocalPropertyNames(names, 0);
for (int i = 0; i < names->length(); i++) {
@@ -143,14 +149,17 @@ MUST_USE_RESULT static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
// In particular, don't try to copy the length attribute of
// an array.
if (attributes != NONE) continue;
- Object* value = copy->GetProperty(key_string, &attributes);
- ASSERT(!value->IsFailure());
+ Object* value =
+ copy->GetProperty(key_string, &attributes)->ToObjectUnchecked();
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(js_object);
- if (result->IsFailure()) return result;
- result = copy->SetProperty(key_string, result, NONE);
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
+ { MaybeObject* maybe_result =
+ copy->SetProperty(key_string, result, NONE);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
}
}
}
@@ -173,8 +182,9 @@ MUST_USE_RESULT static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
Object* value = elements->get(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(js_object);
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
elements->set(i, result);
}
}
@@ -190,8 +200,9 @@ MUST_USE_RESULT static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
Object* value = element_dictionary->ValueAt(i);
if (value->IsJSObject()) {
JSObject* js_object = JSObject::cast(value);
- result = DeepCopyBoilerplate(js_object);
- if (result->IsFailure()) return result;
+ { MaybeObject* maybe_result = DeepCopyBoilerplate(js_object);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
element_dictionary->ValueAtPut(i, result);
}
}
@@ -206,13 +217,13 @@ MUST_USE_RESULT static Object* DeepCopyBoilerplate(JSObject* boilerplate) {
}
-static Object* Runtime_CloneLiteralBoilerplate(Arguments args) {
+static MaybeObject* Runtime_CloneLiteralBoilerplate(Arguments args) {
CONVERT_CHECKED(JSObject, boilerplate, args[0]);
return DeepCopyBoilerplate(boilerplate);
}
-static Object* Runtime_CloneShallowLiteralBoilerplate(Arguments args) {
+static MaybeObject* Runtime_CloneShallowLiteralBoilerplate(Arguments args) {
CONVERT_CHECKED(JSObject, boilerplate, args[0]);
return Heap::CopyJSObject(boilerplate);
}
@@ -403,7 +414,7 @@ static Handle<Object> CreateLiteralBoilerplate(
}
-static Object* Runtime_CreateArrayLiteralBoilerplate(Arguments args) {
+static MaybeObject* Runtime_CreateArrayLiteralBoilerplate(Arguments args) {
// Takes a FixedArray of elements containing the literal elements of
// the array literal and produces JSArray with those elements.
// Additionally takes the literals array of the surrounding function
@@ -424,7 +435,7 @@ static Object* Runtime_CreateArrayLiteralBoilerplate(Arguments args) {
}
-static Object* Runtime_CreateObjectLiteral(Arguments args) {
+static MaybeObject* Runtime_CreateObjectLiteral(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
@@ -447,7 +458,7 @@ static Object* Runtime_CreateObjectLiteral(Arguments args) {
}
-static Object* Runtime_CreateObjectLiteralShallow(Arguments args) {
+static MaybeObject* Runtime_CreateObjectLiteralShallow(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
@@ -470,7 +481,7 @@ static Object* Runtime_CreateObjectLiteralShallow(Arguments args) {
}
-static Object* Runtime_CreateArrayLiteral(Arguments args) {
+static MaybeObject* Runtime_CreateArrayLiteral(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
@@ -489,7 +500,7 @@ static Object* Runtime_CreateArrayLiteral(Arguments args) {
}
-static Object* Runtime_CreateArrayLiteralShallow(Arguments args) {
+static MaybeObject* Runtime_CreateArrayLiteralShallow(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
@@ -512,24 +523,28 @@ static Object* Runtime_CreateArrayLiteralShallow(Arguments args) {
}
-static Object* Runtime_CreateCatchExtensionObject(Arguments args) {
+static MaybeObject* Runtime_CreateCatchExtensionObject(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(String, key, args[0]);
Object* value = args[1];
// Create a catch context extension object.
JSFunction* constructor =
Top::context()->global_context()->context_extension_function();
- Object* object = Heap::AllocateJSObject(constructor);
- if (object->IsFailure()) return object;
+ Object* object;
+ { MaybeObject* maybe_object = Heap::AllocateJSObject(constructor);
+ if (!maybe_object->ToObject(&object)) return maybe_object;
+ }
// Assign the exception value to the catch variable and make sure
// that the catch variable is DontDelete.
- value = JSObject::cast(object)->SetProperty(key, value, DONT_DELETE);
- if (value->IsFailure()) return value;
+ { MaybeObject* maybe_value =
+ JSObject::cast(object)->SetProperty(key, value, DONT_DELETE);
+ if (!maybe_value->ToObject(&value)) return maybe_value;
+ }
return object;
}
-static Object* Runtime_ClassOf(Arguments args) {
+static MaybeObject* Runtime_ClassOf(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Object* obj = args[0];
@@ -538,7 +553,7 @@ static Object* Runtime_ClassOf(Arguments args) {
}
-static Object* Runtime_IsInPrototypeChain(Arguments args) {
+static MaybeObject* Runtime_IsInPrototypeChain(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
// See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8).
@@ -554,7 +569,7 @@ static Object* Runtime_IsInPrototypeChain(Arguments args) {
// Inserts an object as the hidden prototype of another object.
-static Object* Runtime_SetHiddenPrototype(Arguments args) {
+static MaybeObject* Runtime_SetHiddenPrototype(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSObject, jsobject, args[0]);
@@ -568,12 +583,19 @@ static Object* Runtime_SetHiddenPrototype(Arguments args) {
RUNTIME_ASSERT(!proto->map()->is_hidden_prototype());
// Allocate up front before we start altering state in case we get a GC.
- Object* map_or_failure = proto->map()->CopyDropTransitions();
- if (map_or_failure->IsFailure()) return map_or_failure;
+ Object* map_or_failure;
+ { MaybeObject* maybe_map_or_failure = proto->map()->CopyDropTransitions();
+ if (!maybe_map_or_failure->ToObject(&map_or_failure)) {
+ return maybe_map_or_failure;
+ }
+ }
Map* new_proto_map = Map::cast(map_or_failure);
- map_or_failure = jsobject->map()->CopyDropTransitions();
- if (map_or_failure->IsFailure()) return map_or_failure;
+ { MaybeObject* maybe_map_or_failure = jsobject->map()->CopyDropTransitions();
+ if (!maybe_map_or_failure->ToObject(&map_or_failure)) {
+ return maybe_map_or_failure;
+ }
+ }
Map* new_map = Map::cast(map_or_failure);
// Set proto's prototype to be the old prototype of the object.
@@ -589,7 +611,7 @@ static Object* Runtime_SetHiddenPrototype(Arguments args) {
}
-static Object* Runtime_IsConstructCall(Arguments args) {
+static MaybeObject* Runtime_IsConstructCall(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 0);
JavaScriptFrameIterator it;
@@ -632,7 +654,7 @@ enum PropertyDescriptorIndices {
// [false, value, Writeable, Enumerable, Configurable]
// if args[1] is an accessor on args[0]
// [true, GetFunction, SetFunction, Enumerable, Configurable]
-static Object* Runtime_GetOwnProperty(Arguments args) {
+static MaybeObject* Runtime_GetOwnProperty(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
Handle<FixedArray> elms = Factory::NewFixedArray(DESCRIPTOR_SIZE);
@@ -719,9 +741,11 @@ static Object* Runtime_GetOwnProperty(Arguments args) {
if (structure->IsProxy() || structure->IsAccessorInfo()) {
// Property that is internally implemented as a callback or
// an API defined callback.
- Object* value = obj->GetPropertyWithCallback(
- *obj, structure, *name, result.holder());
- if (value->IsFailure()) return value;
+ Object* value;
+ { MaybeObject* maybe_value = obj->GetPropertyWithCallback(
+ *obj, structure, *name, result.holder());
+ if (!maybe_value->ToObject(&value)) return maybe_value;
+ }
elms->set(IS_ACCESSOR_INDEX, Heap::false_value());
elms->set(VALUE_INDEX, value);
elms->set(WRITABLE_INDEX, Heap::ToBoolean(!result.IsReadOnly()));
@@ -745,13 +769,13 @@ static Object* Runtime_GetOwnProperty(Arguments args) {
}
-static Object* Runtime_PreventExtensions(Arguments args) {
+static MaybeObject* Runtime_PreventExtensions(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSObject, obj, args[0]);
return obj->PreventExtensions();
}
-static Object* Runtime_IsExtensible(Arguments args) {
+static MaybeObject* Runtime_IsExtensible(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSObject, obj, args[0]);
return obj->map()->is_extensible() ? Heap::true_value()
@@ -759,7 +783,7 @@ static Object* Runtime_IsExtensible(Arguments args) {
}
-static Object* Runtime_RegExpCompile(Arguments args) {
+static MaybeObject* Runtime_RegExpCompile(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(JSRegExp, re, 0);
@@ -771,7 +795,7 @@ static Object* Runtime_RegExpCompile(Arguments args) {
}
-static Object* Runtime_CreateApiFunction(Arguments args) {
+static MaybeObject* Runtime_CreateApiFunction(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(FunctionTemplateInfo, data, 0);
@@ -779,7 +803,7 @@ static Object* Runtime_CreateApiFunction(Arguments args) {
}
-static Object* Runtime_IsTemplate(Arguments args) {
+static MaybeObject* Runtime_IsTemplate(Arguments args) {
ASSERT(args.length() == 1);
Object* arg = args[0];
bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo();
@@ -787,7 +811,7 @@ static Object* Runtime_IsTemplate(Arguments args) {
}
-static Object* Runtime_GetTemplateField(Arguments args) {
+static MaybeObject* Runtime_GetTemplateField(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(HeapObject, templ, args[0]);
CONVERT_CHECKED(Smi, field, args[1]);
@@ -806,15 +830,17 @@ static Object* Runtime_GetTemplateField(Arguments args) {
}
-static Object* Runtime_DisableAccessChecks(Arguments args) {
+static MaybeObject* Runtime_DisableAccessChecks(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(HeapObject, object, args[0]);
Map* old_map = object->map();
bool needs_access_checks = old_map->is_access_check_needed();
if (needs_access_checks) {
// Copy map so it won't interfere constructor's initial map.
- Object* new_map = old_map->CopyDropTransitions();
- if (new_map->IsFailure()) return new_map;
+ Object* new_map;
+ { MaybeObject* maybe_new_map = old_map->CopyDropTransitions();
+ if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
+ }
Map::cast(new_map)->set_is_access_check_needed(false);
object->set_map(Map::cast(new_map));
@@ -823,14 +849,16 @@ static Object* Runtime_DisableAccessChecks(Arguments args) {
}
-static Object* Runtime_EnableAccessChecks(Arguments args) {
+static MaybeObject* Runtime_EnableAccessChecks(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(HeapObject, object, args[0]);
Map* old_map = object->map();
if (!old_map->is_access_check_needed()) {
// Copy map so it won't interfere constructor's initial map.
- Object* new_map = old_map->CopyDropTransitions();
- if (new_map->IsFailure()) return new_map;
+ Object* new_map;
+ { MaybeObject* maybe_new_map = old_map->CopyDropTransitions();
+ if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
+ }
Map::cast(new_map)->set_is_access_check_needed(true);
object->set_map(Map::cast(new_map));
@@ -839,7 +867,7 @@ static Object* Runtime_EnableAccessChecks(Arguments args) {
}
-static Object* ThrowRedeclarationError(const char* type, Handle<String> name) {
+static Failure* ThrowRedeclarationError(const char* type, Handle<String> name) {
HandleScope scope;
Handle<Object> type_handle = Factory::NewStringFromAscii(CStrVector(type));
Handle<Object> args[2] = { type_handle, name };
@@ -849,7 +877,7 @@ static Object* ThrowRedeclarationError(const char* type, Handle<String> name) {
}
-static Object* Runtime_DeclareGlobals(Arguments args) {
+static MaybeObject* Runtime_DeclareGlobals(Arguments args) {
HandleScope scope;
Handle<GlobalObject> global = Handle<GlobalObject>(Top::context()->global());
@@ -961,7 +989,7 @@ static Object* Runtime_DeclareGlobals(Arguments args) {
}
-static Object* Runtime_DeclareContextSlot(Arguments args) {
+static MaybeObject* Runtime_DeclareContextSlot(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
@@ -1046,7 +1074,7 @@ static Object* Runtime_DeclareContextSlot(Arguments args) {
}
-static Object* Runtime_InitializeVarGlobal(Arguments args) {
+static MaybeObject* Runtime_InitializeVarGlobal(Arguments args) {
NoHandleAllocation nha;
// Determine if we need to assign to the variable if it already
@@ -1139,7 +1167,7 @@ static Object* Runtime_InitializeVarGlobal(Arguments args) {
}
-static Object* Runtime_InitializeConstGlobal(Arguments args) {
+static MaybeObject* Runtime_InitializeConstGlobal(Arguments args) {
// All constants are declared with an initial value. The name
// of the constant is the first argument and the initial value
// is the second.
@@ -1187,12 +1215,13 @@ static Object* Runtime_InitializeConstGlobal(Arguments args) {
// Restore global object from context (in case of GC) and continue
// with setting the value because the property is either absent or
// read-only. We also have to do redo the lookup.
- global = Top::context()->global();
+ HandleScope handle_scope;
+ Handle<GlobalObject>global(Top::context()->global());
// BUG 1213579: Handle the case where we have to set a read-only
// property through an interceptor and only do it if it's
// uninitialized, e.g. the hole. Nirk...
- global->SetProperty(*name, *value, attributes);
+ SetProperty(global, name, value, attributes);
return *value;
}
@@ -1221,7 +1250,7 @@ static Object* Runtime_InitializeConstGlobal(Arguments args) {
}
-static Object* Runtime_InitializeConstContextSlot(Arguments args) {
+static MaybeObject* Runtime_InitializeConstContextSlot(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
@@ -1326,7 +1355,7 @@ static Object* Runtime_InitializeConstContextSlot(Arguments args) {
}
-static Object* Runtime_OptimizeObjectForAddingMultipleProperties(
+static MaybeObject* Runtime_OptimizeObjectForAddingMultipleProperties(
Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -1339,7 +1368,7 @@ static Object* Runtime_OptimizeObjectForAddingMultipleProperties(
}
-static Object* Runtime_RegExpExec(Arguments args) {
+static MaybeObject* Runtime_RegExpExec(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
@@ -1361,19 +1390,23 @@ static Object* Runtime_RegExpExec(Arguments args) {
}
-static Object* Runtime_RegExpConstructResult(Arguments args) {
+static MaybeObject* Runtime_RegExpConstructResult(Arguments args) {
ASSERT(args.length() == 3);
CONVERT_SMI_CHECKED(elements_count, args[0]);
if (elements_count > JSArray::kMaxFastElementsLength) {
return Top::ThrowIllegalOperation();
}
- Object* new_object = Heap::AllocateFixedArrayWithHoles(elements_count);
- if (new_object->IsFailure()) return new_object;
+ Object* new_object;
+ { MaybeObject* maybe_new_object =
+ Heap::AllocateFixedArrayWithHoles(elements_count);
+ if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
+ }
FixedArray* elements = FixedArray::cast(new_object);
- new_object = Heap::AllocateRaw(JSRegExpResult::kSize,
- NEW_SPACE,
- OLD_POINTER_SPACE);
- if (new_object->IsFailure()) return new_object;
+ { MaybeObject* maybe_new_object = Heap::AllocateRaw(JSRegExpResult::kSize,
+ NEW_SPACE,
+ OLD_POINTER_SPACE);
+ if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object;
+ }
{
AssertNoAllocation no_gc;
HandleScope scope;
@@ -1391,7 +1424,7 @@ static Object* Runtime_RegExpConstructResult(Arguments args) {
}
-static Object* Runtime_RegExpCloneResult(Arguments args) {
+static MaybeObject* Runtime_RegExpCloneResult(Arguments args) {
ASSERT(args.length() == 1);
Map* regexp_result_map;
{
@@ -1414,10 +1447,13 @@ static Object* Runtime_RegExpCloneResult(Arguments args) {
ASSERT(result->properties() == Heap::empty_fixed_array());
ASSERT_EQ(2, regexp_result_map->inobject_properties());
- Object* new_array_alloc = Heap::AllocateRaw(JSRegExpResult::kSize,
- NEW_SPACE,
- OLD_POINTER_SPACE);
- if (new_array_alloc->IsFailure()) return new_array_alloc;
+ Object* new_array_alloc;
+ { MaybeObject* maybe_new_array_alloc =
+ Heap::AllocateRaw(JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE);
+ if (!maybe_new_array_alloc->ToObject(&new_array_alloc)) {
+ return maybe_new_array_alloc;
+ }
+ }
// Set HeapObject map to JSRegExpResult map.
reinterpret_cast<HeapObject*>(new_array_alloc)->set_map(regexp_result_map);
@@ -1448,7 +1484,7 @@ static Object* Runtime_RegExpCloneResult(Arguments args) {
}
-static Object* Runtime_RegExpInitializeObject(Arguments args) {
+static MaybeObject* Runtime_RegExpInitializeObject(Arguments args) {
AssertNoAllocation no_alloc;
ASSERT(args.length() == 5);
CONVERT_CHECKED(JSRegExp, regexp, args[0]);
@@ -1480,31 +1516,42 @@ static Object* Runtime_RegExpInitializeObject(Arguments args) {
return regexp;
}
- // Map has changed, so use generic, but slower, method.
+ // Map has changed, so use generic, but slower, method. Since these
+ // properties were all added as DONT_DELETE they must be present and
+ // normal so no failures can be expected.
PropertyAttributes final =
static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE);
PropertyAttributes writable =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
- regexp->IgnoreAttributesAndSetLocalProperty(Heap::source_symbol(),
- source,
- final);
- regexp->IgnoreAttributesAndSetLocalProperty(Heap::global_symbol(),
- global,
- final);
- regexp->IgnoreAttributesAndSetLocalProperty(Heap::ignore_case_symbol(),
- ignoreCase,
- final);
- regexp->IgnoreAttributesAndSetLocalProperty(Heap::multiline_symbol(),
- multiline,
- final);
- regexp->IgnoreAttributesAndSetLocalProperty(Heap::last_index_symbol(),
- Smi::FromInt(0),
- writable);
+ MaybeObject* result;
+ result = regexp->IgnoreAttributesAndSetLocalProperty(Heap::source_symbol(),
+ source,
+ final);
+ ASSERT(!result->IsFailure());
+ result = regexp->IgnoreAttributesAndSetLocalProperty(Heap::global_symbol(),
+ global,
+ final);
+ ASSERT(!result->IsFailure());
+ result =
+ regexp->IgnoreAttributesAndSetLocalProperty(Heap::ignore_case_symbol(),
+ ignoreCase,
+ final);
+ ASSERT(!result->IsFailure());
+ result = regexp->IgnoreAttributesAndSetLocalProperty(Heap::multiline_symbol(),
+ multiline,
+ final);
+ ASSERT(!result->IsFailure());
+ result =
+ regexp->IgnoreAttributesAndSetLocalProperty(Heap::last_index_symbol(),
+ Smi::FromInt(0),
+ writable);
+ ASSERT(!result->IsFailure());
+ USE(result);
return regexp;
}
-static Object* Runtime_FinishArrayPrototypeSetup(Arguments args) {
+static MaybeObject* Runtime_FinishArrayPrototypeSetup(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSArray, prototype, 0);
@@ -1531,7 +1578,7 @@ static Handle<JSFunction> InstallBuiltin(Handle<JSObject> holder,
}
-static Object* Runtime_SpecialArrayFunctions(Arguments args) {
+static MaybeObject* Runtime_SpecialArrayFunctions(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, holder, 0);
@@ -1548,14 +1595,14 @@ static Object* Runtime_SpecialArrayFunctions(Arguments args) {
}
-static Object* Runtime_GetGlobalReceiver(Arguments args) {
+static MaybeObject* Runtime_GetGlobalReceiver(Arguments args) {
// Returns a real global receiver, not one of builtins object.
Context* global_context = Top::context()->global()->global_context();
return global_context->global()->global_receiver();
}
-static Object* Runtime_MaterializeRegExpLiteral(Arguments args) {
+static MaybeObject* Runtime_MaterializeRegExpLiteral(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 4);
CONVERT_ARG_CHECKED(FixedArray, literals, 0);
@@ -1585,7 +1632,7 @@ static Object* Runtime_MaterializeRegExpLiteral(Arguments args) {
}
-static Object* Runtime_FunctionGetName(Arguments args) {
+static MaybeObject* Runtime_FunctionGetName(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -1594,7 +1641,7 @@ static Object* Runtime_FunctionGetName(Arguments args) {
}
-static Object* Runtime_FunctionSetName(Arguments args) {
+static MaybeObject* Runtime_FunctionSetName(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -1605,19 +1652,21 @@ static Object* Runtime_FunctionSetName(Arguments args) {
}
-static Object* Runtime_FunctionRemovePrototype(Arguments args) {
+static MaybeObject* Runtime_FunctionRemovePrototype(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSFunction, f, args[0]);
- Object* obj = f->RemovePrototype();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = f->RemovePrototype();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
return Heap::undefined_value();
}
-static Object* Runtime_FunctionGetScript(Arguments args) {
+static MaybeObject* Runtime_FunctionGetScript(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -1629,7 +1678,7 @@ static Object* Runtime_FunctionGetScript(Arguments args) {
}
-static Object* Runtime_FunctionGetSourceCode(Arguments args) {
+static MaybeObject* Runtime_FunctionGetSourceCode(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -1638,7 +1687,7 @@ static Object* Runtime_FunctionGetSourceCode(Arguments args) {
}
-static Object* Runtime_FunctionGetScriptSourcePosition(Arguments args) {
+static MaybeObject* Runtime_FunctionGetScriptSourcePosition(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -1648,7 +1697,7 @@ static Object* Runtime_FunctionGetScriptSourcePosition(Arguments args) {
}
-static Object* Runtime_FunctionGetPositionForOffset(Arguments args) {
+static MaybeObject* Runtime_FunctionGetPositionForOffset(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSFunction, fun, args[0]);
@@ -1663,7 +1712,7 @@ static Object* Runtime_FunctionGetPositionForOffset(Arguments args) {
-static Object* Runtime_FunctionSetInstanceClassName(Arguments args) {
+static MaybeObject* Runtime_FunctionSetInstanceClassName(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -1674,7 +1723,7 @@ static Object* Runtime_FunctionSetInstanceClassName(Arguments args) {
}
-static Object* Runtime_FunctionSetLength(Arguments args) {
+static MaybeObject* Runtime_FunctionSetLength(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -1685,19 +1734,22 @@ static Object* Runtime_FunctionSetLength(Arguments args) {
}
-static Object* Runtime_FunctionSetPrototype(Arguments args) {
+static MaybeObject* Runtime_FunctionSetPrototype(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSFunction, fun, args[0]);
ASSERT(fun->should_have_prototype());
- Object* obj = Accessors::FunctionSetPrototype(fun, args[1], NULL);
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj =
+ Accessors::FunctionSetPrototype(fun, args[1], NULL);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
return args[0]; // return TOS
}
-static Object* Runtime_FunctionIsAPIFunction(Arguments args) {
+static MaybeObject* Runtime_FunctionIsAPIFunction(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -1706,7 +1758,7 @@ static Object* Runtime_FunctionIsAPIFunction(Arguments args) {
: Heap::false_value();
}
-static Object* Runtime_FunctionIsBuiltin(Arguments args) {
+static MaybeObject* Runtime_FunctionIsBuiltin(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -1715,7 +1767,7 @@ static Object* Runtime_FunctionIsBuiltin(Arguments args) {
}
-static Object* Runtime_SetCode(Arguments args) {
+static MaybeObject* Runtime_SetCode(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -1772,7 +1824,7 @@ static Object* Runtime_SetCode(Arguments args) {
}
-static Object* Runtime_SetExpectedNumberOfProperties(Arguments args) {
+static MaybeObject* Runtime_SetExpectedNumberOfProperties(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSFunction, function, 0);
@@ -1783,7 +1835,7 @@ static Object* Runtime_SetExpectedNumberOfProperties(Arguments args) {
}
-static Object* CharFromCode(Object* char_code) {
+MUST_USE_RESULT static MaybeObject* CharFromCode(Object* char_code) {
uint32_t code;
if (char_code->ToArrayIndex(&code)) {
if (code <= 0xffff) {
@@ -1794,7 +1846,7 @@ static Object* CharFromCode(Object* char_code) {
}
-static Object* Runtime_StringCharCodeAt(Arguments args) {
+static MaybeObject* Runtime_StringCharCodeAt(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -1816,8 +1868,10 @@ static Object* Runtime_StringCharCodeAt(Arguments args) {
// Flatten the string. If someone wants to get a char at an index
// in a cons string, it is likely that more indices will be
// accessed.
- Object* flat = subject->TryFlatten();
- if (flat->IsFailure()) return flat;
+ Object* flat;
+ { MaybeObject* maybe_flat = subject->TryFlatten();
+ if (!maybe_flat->ToObject(&flat)) return maybe_flat;
+ }
subject = String::cast(flat);
if (i >= static_cast<uint32_t>(subject->length())) {
@@ -1828,7 +1882,7 @@ static Object* Runtime_StringCharCodeAt(Arguments args) {
}
-static Object* Runtime_CharFromCode(Arguments args) {
+static MaybeObject* Runtime_CharFromCode(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
return CharFromCode(args[0]);
@@ -2317,10 +2371,11 @@ void CompiledReplacement::Apply(ReplacementStringBuilder* builder,
-static Object* StringReplaceRegExpWithString(String* subject,
- JSRegExp* regexp,
- String* replacement,
- JSArray* last_match_info) {
+MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithString(
+ String* subject,
+ JSRegExp* regexp,
+ String* replacement,
+ JSArray* last_match_info) {
ASSERT(subject->IsFlat());
ASSERT(replacement->IsFlat());
@@ -2425,9 +2480,10 @@ static Object* StringReplaceRegExpWithString(String* subject,
template <typename ResultSeqString>
-static Object* StringReplaceRegExpWithEmptyString(String* subject,
- JSRegExp* regexp,
- JSArray* last_match_info) {
+MUST_USE_RESULT static MaybeObject* StringReplaceRegExpWithEmptyString(
+ String* subject,
+ JSRegExp* regexp,
+ JSArray* last_match_info) {
ASSERT(subject->IsFlat());
HandleScope handles;
@@ -2552,23 +2608,27 @@ static Object* StringReplaceRegExpWithEmptyString(String* subject,
}
-static Object* Runtime_StringReplaceRegExpWithString(Arguments args) {
+static MaybeObject* Runtime_StringReplaceRegExpWithString(Arguments args) {
ASSERT(args.length() == 4);
CONVERT_CHECKED(String, subject, args[0]);
if (!subject->IsFlat()) {
- Object* flat_subject = subject->TryFlatten();
- if (flat_subject->IsFailure()) {
- return flat_subject;
+ Object* flat_subject;
+ { MaybeObject* maybe_flat_subject = subject->TryFlatten();
+ if (!maybe_flat_subject->ToObject(&flat_subject)) {
+ return maybe_flat_subject;
+ }
}
subject = String::cast(flat_subject);
}
CONVERT_CHECKED(String, replacement, args[2]);
if (!replacement->IsFlat()) {
- Object* flat_replacement = replacement->TryFlatten();
- if (flat_replacement->IsFailure()) {
- return flat_replacement;
+ Object* flat_replacement;
+ { MaybeObject* maybe_flat_replacement = replacement->TryFlatten();
+ if (!maybe_flat_replacement->ToObject(&flat_replacement)) {
+ return maybe_flat_replacement;
+ }
}
replacement = String::cast(flat_replacement);
}
@@ -2636,7 +2696,7 @@ int Runtime::StringMatch(Handle<String> sub,
}
-static Object* Runtime_StringIndexOf(Arguments args) {
+static MaybeObject* Runtime_StringIndexOf(Arguments args) {
HandleScope scope; // create a new handle scope
ASSERT(args.length() == 3);
@@ -2687,7 +2747,7 @@ static int StringMatchBackwards(Vector<const schar> subject,
return -1;
}
-static Object* Runtime_StringLastIndexOf(Arguments args) {
+static MaybeObject* Runtime_StringLastIndexOf(Arguments args) {
HandleScope scope; // create a new handle scope
ASSERT(args.length() == 3);
@@ -2744,7 +2804,7 @@ static Object* Runtime_StringLastIndexOf(Arguments args) {
}
-static Object* Runtime_StringLocaleCompare(Arguments args) {
+static MaybeObject* Runtime_StringLocaleCompare(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -2790,7 +2850,7 @@ static Object* Runtime_StringLocaleCompare(Arguments args) {
}
-static Object* Runtime_SubString(Arguments args) {
+static MaybeObject* Runtime_SubString(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
@@ -2817,7 +2877,7 @@ static Object* Runtime_SubString(Arguments args) {
}
-static Object* Runtime_StringMatch(Arguments args) {
+static MaybeObject* Runtime_StringMatch(Arguments args) {
ASSERT_EQ(3, args.length());
CONVERT_ARG_CHECKED(String, subject, 0);
@@ -3172,7 +3232,7 @@ static RegExpImpl::IrregexpResult SearchRegExpMultiple(
}
-static Object* Runtime_RegExpExecMultiple(Arguments args) {
+static MaybeObject* Runtime_RegExpExecMultiple(Arguments args) {
ASSERT(args.length() == 4);
HandleScope handles;
@@ -3221,7 +3281,7 @@ static Object* Runtime_RegExpExecMultiple(Arguments args) {
}
-static Object* Runtime_NumberToRadixString(Arguments args) {
+static MaybeObject* Runtime_NumberToRadixString(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3252,13 +3312,13 @@ static Object* Runtime_NumberToRadixString(Arguments args) {
int radix = FastD2I(radix_number);
RUNTIME_ASSERT(2 <= radix && radix <= 36);
char* str = DoubleToRadixCString(value, radix);
- Object* result = Heap::AllocateStringFromAscii(CStrVector(str));
+ MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
DeleteArray(str);
return result;
}
-static Object* Runtime_NumberToFixed(Arguments args) {
+static MaybeObject* Runtime_NumberToFixed(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3276,13 +3336,13 @@ static Object* Runtime_NumberToFixed(Arguments args) {
int f = FastD2I(f_number);
RUNTIME_ASSERT(f >= 0);
char* str = DoubleToFixedCString(value, f);
- Object* res = Heap::AllocateStringFromAscii(CStrVector(str));
+ MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
DeleteArray(str);
- return res;
+ return result;
}
-static Object* Runtime_NumberToExponential(Arguments args) {
+static MaybeObject* Runtime_NumberToExponential(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3300,13 +3360,13 @@ static Object* Runtime_NumberToExponential(Arguments args) {
int f = FastD2I(f_number);
RUNTIME_ASSERT(f >= -1 && f <= 20);
char* str = DoubleToExponentialCString(value, f);
- Object* res = Heap::AllocateStringFromAscii(CStrVector(str));
+ MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
DeleteArray(str);
- return res;
+ return result;
}
-static Object* Runtime_NumberToPrecision(Arguments args) {
+static MaybeObject* Runtime_NumberToPrecision(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3324,9 +3384,9 @@ static Object* Runtime_NumberToPrecision(Arguments args) {
int f = FastD2I(f_number);
RUNTIME_ASSERT(f >= 1 && f <= 21);
char* str = DoubleToPrecisionCString(value, f);
- Object* res = Heap::AllocateStringFromAscii(CStrVector(str));
+ MaybeObject* result = Heap::AllocateStringFromAscii(CStrVector(str));
DeleteArray(str);
- return res;
+ return result;
}
@@ -3342,7 +3402,8 @@ static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) {
}
-Object* Runtime::GetElementOrCharAt(Handle<Object> object, uint32_t index) {
+MaybeObject* Runtime::GetElementOrCharAt(Handle<Object> object,
+ uint32_t index) {
// Handle [] indexing on Strings
if (object->IsString()) {
Handle<Object> result = GetCharAt(Handle<String>::cast(object), index);
@@ -3366,12 +3427,13 @@ Object* Runtime::GetElementOrCharAt(Handle<Object> object, uint32_t index) {
}
-Object* Runtime::GetElement(Handle<Object> object, uint32_t index) {
+MaybeObject* Runtime::GetElement(Handle<Object> object, uint32_t index) {
return object->GetElement(index);
}
-Object* Runtime::GetObjectProperty(Handle<Object> object, Handle<Object> key) {
+MaybeObject* Runtime::GetObjectProperty(Handle<Object> object,
+ Handle<Object> key) {
HandleScope scope;
if (object->IsUndefined() || object->IsNull()) {
@@ -3411,7 +3473,7 @@ Object* Runtime::GetObjectProperty(Handle<Object> object, Handle<Object> key) {
}
-static Object* Runtime_GetProperty(Arguments args) {
+static MaybeObject* Runtime_GetProperty(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3423,7 +3485,7 @@ static Object* Runtime_GetProperty(Arguments args) {
// KeyedStringGetProperty is called from KeyedLoadIC::GenerateGeneric.
-static Object* Runtime_KeyedGetProperty(Arguments args) {
+static MaybeObject* Runtime_KeyedGetProperty(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3488,7 +3550,7 @@ static Object* Runtime_KeyedGetProperty(Arguments args) {
}
-static Object* Runtime_DefineOrRedefineAccessorProperty(Arguments args) {
+static MaybeObject* Runtime_DefineOrRedefineAccessorProperty(Arguments args) {
ASSERT(args.length() == 5);
HandleScope scope;
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -3509,13 +3571,16 @@ static Object* Runtime_DefineOrRedefineAccessorProperty(Arguments args) {
if (result.IsProperty() &&
(result.type() == FIELD || result.type() == NORMAL
|| result.type() == CONSTANT_FUNCTION)) {
- Object* ok = obj->DeleteProperty(name, JSObject::NORMAL_DELETION);
- if (ok->IsFailure()) return ok;
+ Object* ok;
+ { MaybeObject* maybe_ok =
+ obj->DeleteProperty(name, JSObject::NORMAL_DELETION);
+ if (!maybe_ok->ToObject(&ok)) return maybe_ok;
+ }
}
return obj->DefineAccessor(name, flag_setter->value() == 0, fun, attr);
}
-static Object* Runtime_DefineOrRedefineDataProperty(Arguments args) {
+static MaybeObject* Runtime_DefineOrRedefineDataProperty(Arguments args) {
ASSERT(args.length() == 4);
HandleScope scope;
CONVERT_ARG_CHECKED(JSObject, js_object, 0);
@@ -3538,12 +3603,12 @@ static Object* Runtime_DefineOrRedefineDataProperty(Arguments args) {
if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) &&
is_element) {
// Normalize the elements to enable attributes on the property.
- js_object->NormalizeElements();
- NumberDictionary* dictionary = js_object->element_dictionary();
+ NormalizeElements(js_object);
+ Handle<NumberDictionary> dictionary(js_object->element_dictionary());
// Make sure that we never go back to fast case.
dictionary->set_requires_slow_elements();
PropertyDetails details = PropertyDetails(attr, NORMAL);
- dictionary->Set(index, *obj_value, details);
+ NumberDictionarySet(dictionary, index, obj_value, details);
}
LookupResult result;
@@ -3557,7 +3622,7 @@ static Object* Runtime_DefineOrRedefineDataProperty(Arguments args) {
// new attributes.
if (result.IsProperty() && attr != result.GetAttributes()) {
// New attributes - normalize to avoid writing to instance descriptor
- js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
+ NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0);
// Use IgnoreAttributes version since a readonly property may be
// overridden and SetProperty does not allow this.
return js_object->IgnoreAttributesAndSetLocalProperty(*name,
@@ -3569,10 +3634,10 @@ static Object* Runtime_DefineOrRedefineDataProperty(Arguments args) {
}
-Object* Runtime::SetObjectProperty(Handle<Object> object,
- Handle<Object> key,
- Handle<Object> value,
- PropertyAttributes attr) {
+MaybeObject* Runtime::SetObjectProperty(Handle<Object> object,
+ Handle<Object> key,
+ Handle<Object> value,
+ PropertyAttributes attr) {
HandleScope scope;
if (object->IsUndefined() || object->IsNull()) {
@@ -3634,10 +3699,10 @@ Object* Runtime::SetObjectProperty(Handle<Object> object,
}
-Object* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object,
- Handle<Object> key,
- Handle<Object> value,
- PropertyAttributes attr) {
+MaybeObject* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object,
+ Handle<Object> key,
+ Handle<Object> value,
+ PropertyAttributes attr) {
HandleScope scope;
// Check if the given key is an array index.
@@ -3683,8 +3748,8 @@ Object* Runtime::ForceSetObjectProperty(Handle<JSObject> js_object,
}
-Object* Runtime::ForceDeleteObjectProperty(Handle<JSObject> js_object,
- Handle<Object> key) {
+MaybeObject* Runtime::ForceDeleteObjectProperty(Handle<JSObject> js_object,
+ Handle<Object> key) {
HandleScope scope;
// Check if the given key is an array index.
@@ -3719,7 +3784,7 @@ Object* Runtime::ForceDeleteObjectProperty(Handle<JSObject> js_object,
}
-static Object* Runtime_SetProperty(Arguments args) {
+static MaybeObject* Runtime_SetProperty(Arguments args) {
NoHandleAllocation ha;
RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
@@ -3743,7 +3808,7 @@ static Object* Runtime_SetProperty(Arguments args) {
// Set a local property, even if it is READ_ONLY. If the property does not
// exist, it will be added with attributes NONE.
-static Object* Runtime_IgnoreAttributesAndSetProperty(Arguments args) {
+static MaybeObject* Runtime_IgnoreAttributesAndSetProperty(Arguments args) {
NoHandleAllocation ha;
RUNTIME_ASSERT(args.length() == 3 || args.length() == 4);
CONVERT_CHECKED(JSObject, object, args[0]);
@@ -3764,7 +3829,7 @@ static Object* Runtime_IgnoreAttributesAndSetProperty(Arguments args) {
}
-static Object* Runtime_DeleteProperty(Arguments args) {
+static MaybeObject* Runtime_DeleteProperty(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3789,7 +3854,7 @@ static Object* HasLocalPropertyImplementation(Handle<JSObject> object,
}
-static Object* Runtime_HasLocalProperty(Arguments args) {
+static MaybeObject* Runtime_HasLocalProperty(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
CONVERT_CHECKED(String, key, args[1]);
@@ -3818,7 +3883,7 @@ static Object* Runtime_HasLocalProperty(Arguments args) {
}
-static Object* Runtime_HasProperty(Arguments args) {
+static MaybeObject* Runtime_HasProperty(Arguments args) {
NoHandleAllocation na;
ASSERT(args.length() == 2);
@@ -3832,7 +3897,7 @@ static Object* Runtime_HasProperty(Arguments args) {
}
-static Object* Runtime_HasElement(Arguments args) {
+static MaybeObject* Runtime_HasElement(Arguments args) {
NoHandleAllocation na;
ASSERT(args.length() == 2);
@@ -3847,7 +3912,7 @@ static Object* Runtime_HasElement(Arguments args) {
}
-static Object* Runtime_IsPropertyEnumerable(Arguments args) {
+static MaybeObject* Runtime_IsPropertyEnumerable(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -3864,7 +3929,7 @@ static Object* Runtime_IsPropertyEnumerable(Arguments args) {
}
-static Object* Runtime_GetPropertyNames(Arguments args) {
+static MaybeObject* Runtime_GetPropertyNames(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, object, 0);
@@ -3877,7 +3942,7 @@ static Object* Runtime_GetPropertyNames(Arguments args) {
// all enumerable properties of the object and its prototypes
// have none, the map of the object. This is used to speed up
// the check for deletions during a for-in.
-static Object* Runtime_GetPropertyNamesFast(Arguments args) {
+static MaybeObject* Runtime_GetPropertyNamesFast(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSObject, raw_object, args[0]);
@@ -3913,7 +3978,7 @@ static int LocalPrototypeChainLength(JSObject* obj) {
// Return the names of the local named properties.
// args[0]: object
-static Object* Runtime_GetLocalPropertyNames(Arguments args) {
+static MaybeObject* Runtime_GetLocalPropertyNames(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
if (!args[0]->IsJSObject()) {
@@ -3996,7 +4061,7 @@ static Object* Runtime_GetLocalPropertyNames(Arguments args) {
// Return the names of the local indexed properties.
// args[0]: object
-static Object* Runtime_GetLocalElementNames(Arguments args) {
+static MaybeObject* Runtime_GetLocalElementNames(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
if (!args[0]->IsJSObject()) {
@@ -4013,7 +4078,7 @@ static Object* Runtime_GetLocalElementNames(Arguments args) {
// Return information on whether an object has a named or indexed interceptor.
// args[0]: object
-static Object* Runtime_GetInterceptorInfo(Arguments args) {
+static MaybeObject* Runtime_GetInterceptorInfo(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
if (!args[0]->IsJSObject()) {
@@ -4031,7 +4096,7 @@ static Object* Runtime_GetInterceptorInfo(Arguments args) {
// Return property names from named interceptor.
// args[0]: object
-static Object* Runtime_GetNamedInterceptorPropertyNames(Arguments args) {
+static MaybeObject* Runtime_GetNamedInterceptorPropertyNames(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -4046,7 +4111,7 @@ static Object* Runtime_GetNamedInterceptorPropertyNames(Arguments args) {
// Return element names from indexed interceptor.
// args[0]: object
-static Object* Runtime_GetIndexedInterceptorElementNames(Arguments args) {
+static MaybeObject* Runtime_GetIndexedInterceptorElementNames(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -4059,7 +4124,7 @@ static Object* Runtime_GetIndexedInterceptorElementNames(Arguments args) {
}
-static Object* Runtime_LocalKeys(Arguments args) {
+static MaybeObject* Runtime_LocalKeys(Arguments args) {
ASSERT_EQ(args.length(), 1);
CONVERT_CHECKED(JSObject, raw_object, args[0]);
HandleScope scope;
@@ -4087,7 +4152,7 @@ static Object* Runtime_LocalKeys(Arguments args) {
}
-static Object* Runtime_GetArgumentsProperty(Arguments args) {
+static MaybeObject* Runtime_GetArgumentsProperty(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4132,7 +4197,7 @@ static Object* Runtime_GetArgumentsProperty(Arguments args) {
}
-static Object* Runtime_ToFastProperties(Arguments args) {
+static MaybeObject* Runtime_ToFastProperties(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -4140,27 +4205,28 @@ static Object* Runtime_ToFastProperties(Arguments args) {
if (object->IsJSObject()) {
Handle<JSObject> js_object = Handle<JSObject>::cast(object);
if (!js_object->HasFastProperties() && !js_object->IsGlobalObject()) {
- js_object->TransformToFastProperties(0);
+ MaybeObject* ok = js_object->TransformToFastProperties(0);
+ if (ok->IsRetryAfterGC()) return ok;
}
}
return *object;
}
-static Object* Runtime_ToSlowProperties(Arguments args) {
+static MaybeObject* Runtime_ToSlowProperties(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
Handle<Object> object = args.at<Object>(0);
if (object->IsJSObject()) {
Handle<JSObject> js_object = Handle<JSObject>::cast(object);
- js_object->NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
+ NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0);
}
return *object;
}
-static Object* Runtime_ToBool(Arguments args) {
+static MaybeObject* Runtime_ToBool(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4170,7 +4236,7 @@ static Object* Runtime_ToBool(Arguments args) {
// Returns the type string of a value; see ECMA-262, 11.4.3 (p 47).
// Possible optimizations: put the type string into the oddballs.
-static Object* Runtime_Typeof(Arguments args) {
+static MaybeObject* Runtime_Typeof(Arguments args) {
NoHandleAllocation ha;
Object* obj = args[0];
@@ -4227,7 +4293,7 @@ static int ParseDecimalInteger(const char*s, int from, int to) {
}
-static Object* Runtime_StringToNumber(Arguments args) {
+static MaybeObject* Runtime_StringToNumber(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(String, subject, args[0]);
@@ -4281,7 +4347,7 @@ static Object* Runtime_StringToNumber(Arguments args) {
}
-static Object* Runtime_StringFromCharCodeArray(Arguments args) {
+static MaybeObject* Runtime_StringFromCharCodeArray(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4291,23 +4357,32 @@ static Object* Runtime_StringFromCharCodeArray(Arguments args) {
// Check if the string can be ASCII.
int i;
for (i = 0; i < length; i++) {
- Object* element = codes->GetElement(i);
+ Object* element;
+ { MaybeObject* maybe_element = codes->GetElement(i);
+ // We probably can't get an exception here, but just in order to enforce
+ // the checking of inputs in the runtime calls we check here.
+ if (!maybe_element->ToObject(&element)) return maybe_element;
+ }
CONVERT_NUMBER_CHECKED(int, chr, Int32, element);
if ((chr & 0xffff) > String::kMaxAsciiCharCode)
break;
}
- Object* object = NULL;
+ MaybeObject* maybe_object = NULL;
if (i == length) { // The string is ASCII.
- object = Heap::AllocateRawAsciiString(length);
+ maybe_object = Heap::AllocateRawAsciiString(length);
} else { // The string is not ASCII.
- object = Heap::AllocateRawTwoByteString(length);
+ maybe_object = Heap::AllocateRawTwoByteString(length);
}
- if (object->IsFailure()) return object;
+ Object* object = NULL;
+ if (!maybe_object->ToObject(&object)) return maybe_object;
String* result = String::cast(object);
for (int i = 0; i < length; i++) {
- Object* element = codes->GetElement(i);
+ Object* element;
+ { MaybeObject* maybe_element = codes->GetElement(i);
+ if (!maybe_element->ToObject(&element)) return maybe_element;
+ }
CONVERT_NUMBER_CHECKED(int, chr, Int32, element);
result->Set(i, chr & 0xffff);
}
@@ -4352,7 +4427,7 @@ static bool IsNotEscaped(uint16_t character) {
}
-static Object* Runtime_URIEscape(Arguments args) {
+static MaybeObject* Runtime_URIEscape(Arguments args) {
const char hex_chars[] = "0123456789ABCDEF";
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4386,8 +4461,10 @@ static Object* Runtime_URIEscape(Arguments args) {
if (escaped_length == length) {
return source;
}
- Object* o = Heap::AllocateRawAsciiString(escaped_length);
- if (o->IsFailure()) return o;
+ Object* o;
+ { MaybeObject* maybe_o = Heap::AllocateRawAsciiString(escaped_length);
+ if (!maybe_o->ToObject(&o)) return maybe_o;
+ }
String* destination = String::cast(o);
int dest_position = 0;
@@ -4466,7 +4543,7 @@ static inline int Unescape(String* source,
}
-static Object* Runtime_URIUnescape(Arguments args) {
+static MaybeObject* Runtime_URIUnescape(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(String, source, args[0]);
@@ -4489,10 +4566,12 @@ static Object* Runtime_URIUnescape(Arguments args) {
if (unescaped_length == length)
return source;
- Object* o = ascii ?
- Heap::AllocateRawAsciiString(unescaped_length) :
- Heap::AllocateRawTwoByteString(unescaped_length);
- if (o->IsFailure()) return o;
+ Object* o;
+ { MaybeObject* maybe_o = ascii ?
+ Heap::AllocateRawAsciiString(unescaped_length) :
+ Heap::AllocateRawTwoByteString(unescaped_length);
+ if (!maybe_o->ToObject(&o)) return maybe_o;
+ }
String* destination = String::cast(o);
int dest_position = 0;
@@ -4505,7 +4584,7 @@ static Object* Runtime_URIUnescape(Arguments args) {
}
-static Object* Runtime_StringParseInt(Arguments args) {
+static MaybeObject* Runtime_StringParseInt(Arguments args) {
NoHandleAllocation ha;
CONVERT_CHECKED(String, s, args[0]);
@@ -4519,7 +4598,7 @@ static Object* Runtime_StringParseInt(Arguments args) {
}
-static Object* Runtime_StringParseFloat(Arguments args) {
+static MaybeObject* Runtime_StringParseFloat(Arguments args) {
NoHandleAllocation ha;
CONVERT_CHECKED(String, str, args[0]);
@@ -4536,10 +4615,11 @@ static unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping;
template <class Converter>
-static Object* ConvertCaseHelper(String* s,
- int length,
- int input_string_length,
- unibrow::Mapping<Converter, 128>* mapping) {
+MUST_USE_RESULT static MaybeObject* ConvertCaseHelper(
+ String* s,
+ int length,
+ int input_string_length,
+ unibrow::Mapping<Converter, 128>* mapping) {
// We try this twice, once with the assumption that the result is no longer
// than the input and, if that assumption breaks, again with the exact
// length. This may not be pretty, but it is nicer than what was here before
@@ -4551,10 +4631,12 @@ static Object* ConvertCaseHelper(String* s,
// character is also ascii. This is currently the case, but it
// might break in the future if we implement more context and locale
// dependent upper/lower conversions.
- Object* o = s->IsAsciiRepresentation()
- ? Heap::AllocateRawAsciiString(length)
- : Heap::AllocateRawTwoByteString(length);
- if (o->IsFailure()) return o;
+ Object* o;
+ { MaybeObject* maybe_o = s->IsAsciiRepresentation()
+ ? Heap::AllocateRawAsciiString(length)
+ : Heap::AllocateRawTwoByteString(length);
+ if (!maybe_o->ToObject(&o)) return maybe_o;
+ }
String* result = String::cast(o);
bool has_changed_character = false;
@@ -4636,46 +4718,134 @@ static Object* ConvertCaseHelper(String* s,
namespace {
-struct ToLowerTraits {
- typedef unibrow::ToLowercase UnibrowConverter;
+static const uintptr_t kOneInEveryByte = kUintptrAllBitsSet / 0xFF;
+
+
+// Given a word and two range boundaries returns a word with high bit
+// set in every byte iff the corresponding input byte was strictly in
+// the range (m, n). All the other bits in the result are cleared.
+// This function is only useful when it can be inlined and the
+// boundaries are statically known.
+// Requires: all bytes in the input word and the boundaries must be
+// ascii (less than 0x7F).
+static inline uintptr_t AsciiRangeMask(uintptr_t w, char m, char n) {
+ // Every byte in an ascii string is less than or equal to 0x7F.
+ ASSERT((w & (kOneInEveryByte * 0x7F)) == w);
+ // Use strict inequalities since in edge cases the function could be
+ // further simplified.
+ ASSERT(0 < m && m < n && n < 0x7F);
+ // Has high bit set in every w byte less than n.
+ uintptr_t tmp1 = kOneInEveryByte * (0x7F + n) - w;
+ // Has high bit set in every w byte greater than m.
+ uintptr_t tmp2 = w + kOneInEveryByte * (0x7F - m);
+ return (tmp1 & tmp2 & (kOneInEveryByte * 0x80));
+}
+
+
+enum AsciiCaseConversion {
+ ASCII_TO_LOWER,
+ ASCII_TO_UPPER
+};
- static bool ConvertAscii(char* dst, char* src, int length) {
+
+template <AsciiCaseConversion dir>
+struct FastAsciiConverter {
+ static bool Convert(char* dst, char* src, int length) {
+#ifdef DEBUG
+ char* saved_dst = dst;
+ char* saved_src = src;
+#endif
+ // We rely on the distance between upper and lower case letters
+ // being a known power of 2.
+ ASSERT('a' - 'A' == (1 << 5));
+ // Boundaries for the range of input characters than require conversion.
+ const char lo = (dir == ASCII_TO_LOWER) ? 'A' - 1 : 'a' - 1;
+ const char hi = (dir == ASCII_TO_LOWER) ? 'Z' + 1 : 'z' + 1;
bool changed = false;
- for (int i = 0; i < length; ++i) {
- char c = src[i];
- if ('A' <= c && c <= 'Z') {
- c += ('a' - 'A');
+ char* const limit = src + length;
+#ifdef V8_HOST_CAN_READ_UNALIGNED
+ // Process the prefix of the input that requires no conversion one
+ // (machine) word at a time.
+ while (src <= limit - sizeof(uintptr_t)) {
+ uintptr_t w = *reinterpret_cast<uintptr_t*>(src);
+ if (AsciiRangeMask(w, lo, hi) != 0) {
changed = true;
+ break;
}
- dst[i] = c;
+ *reinterpret_cast<uintptr_t*>(dst) = w;
+ src += sizeof(uintptr_t);
+ dst += sizeof(uintptr_t);
+ }
+ // Process the remainder of the input performing conversion when
+ // required one word at a time.
+ while (src <= limit - sizeof(uintptr_t)) {
+ uintptr_t w = *reinterpret_cast<uintptr_t*>(src);
+ uintptr_t m = AsciiRangeMask(w, lo, hi);
+ // The mask has high (7th) bit set in every byte that needs
+ // conversion and we know that the distance between cases is
+ // 1 << 5.
+ *reinterpret_cast<uintptr_t*>(dst) = w ^ (m >> 2);
+ src += sizeof(uintptr_t);
+ dst += sizeof(uintptr_t);
}
+#endif
+ // Process the last few bytes of the input (or the whole input if
+ // unaligned access is not supported).
+ while (src < limit) {
+ char c = *src;
+ if (lo < c && c < hi) {
+ c ^= (1 << 5);
+ changed = true;
+ }
+ *dst = c;
+ ++src;
+ ++dst;
+ }
+#ifdef DEBUG
+ CheckConvert(saved_dst, saved_src, length, changed);
+#endif
return changed;
}
+
+#ifdef DEBUG
+ static void CheckConvert(char* dst, char* src, int length, bool changed) {
+ bool expected_changed = false;
+ for (int i = 0; i < length; i++) {
+ if (dst[i] == src[i]) continue;
+ expected_changed = true;
+ if (dir == ASCII_TO_LOWER) {
+ ASSERT('A' <= src[i] && src[i] <= 'Z');
+ ASSERT(dst[i] == src[i] + ('a' - 'A'));
+ } else {
+ ASSERT(dir == ASCII_TO_UPPER);
+ ASSERT('a' <= src[i] && src[i] <= 'z');
+ ASSERT(dst[i] == src[i] - ('a' - 'A'));
+ }
+ }
+ ASSERT(expected_changed == changed);
+ }
+#endif
+};
+
+
+struct ToLowerTraits {
+ typedef unibrow::ToLowercase UnibrowConverter;
+
+ typedef FastAsciiConverter<ASCII_TO_LOWER> AsciiConverter;
};
struct ToUpperTraits {
typedef unibrow::ToUppercase UnibrowConverter;
- static bool ConvertAscii(char* dst, char* src, int length) {
- bool changed = false;
- for (int i = 0; i < length; ++i) {
- char c = src[i];
- if ('a' <= c && c <= 'z') {
- c -= ('a' - 'A');
- changed = true;
- }
- dst[i] = c;
- }
- return changed;
- }
+ typedef FastAsciiConverter<ASCII_TO_UPPER> AsciiConverter;
};
} // namespace
template <typename ConvertTraits>
-static Object* ConvertCase(
+MUST_USE_RESULT static MaybeObject* ConvertCase(
Arguments args,
unibrow::Mapping<typename ConvertTraits::UnibrowConverter, 128>* mapping) {
NoHandleAllocation ha;
@@ -4693,29 +4863,37 @@ static Object* ConvertCase(
// might break in the future if we implement more context and locale
// dependent upper/lower conversions.
if (s->IsSeqAsciiString()) {
- Object* o = Heap::AllocateRawAsciiString(length);
- if (o->IsFailure()) return o;
+ Object* o;
+ { MaybeObject* maybe_o = Heap::AllocateRawAsciiString(length);
+ if (!maybe_o->ToObject(&o)) return maybe_o;
+ }
SeqAsciiString* result = SeqAsciiString::cast(o);
- bool has_changed_character = ConvertTraits::ConvertAscii(
+ bool has_changed_character = ConvertTraits::AsciiConverter::Convert(
result->GetChars(), SeqAsciiString::cast(s)->GetChars(), length);
return has_changed_character ? result : s;
}
- Object* answer = ConvertCaseHelper(s, length, length, mapping);
+ Object* answer;
+ { MaybeObject* maybe_answer = ConvertCaseHelper(s, length, length, mapping);
+ if (!maybe_answer->ToObject(&answer)) return maybe_answer;
+ }
if (answer->IsSmi()) {
// Retry with correct length.
- answer = ConvertCaseHelper(s, Smi::cast(answer)->value(), length, mapping);
+ { MaybeObject* maybe_answer =
+ ConvertCaseHelper(s, Smi::cast(answer)->value(), length, mapping);
+ if (!maybe_answer->ToObject(&answer)) return maybe_answer;
+ }
}
- return answer; // This may be a failure.
+ return answer;
}
-static Object* Runtime_StringToLowerCase(Arguments args) {
+static MaybeObject* Runtime_StringToLowerCase(Arguments args) {
return ConvertCase<ToLowerTraits>(args, &to_lower_mapping);
}
-static Object* Runtime_StringToUpperCase(Arguments args) {
+static MaybeObject* Runtime_StringToUpperCase(Arguments args) {
return ConvertCase<ToUpperTraits>(args, &to_upper_mapping);
}
@@ -4725,7 +4903,7 @@ static inline bool IsTrimWhiteSpace(unibrow::uchar c) {
}
-static Object* Runtime_StringTrim(Arguments args) {
+static MaybeObject* Runtime_StringTrim(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
@@ -4774,7 +4952,7 @@ void FindStringIndices(Vector<const SubjectChar> subject,
}
-static Object* Runtime_StringSplit(Arguments args) {
+static MaybeObject* Runtime_StringSplit(Arguments args) {
ASSERT(args.length() == 3);
HandleScope handle_scope;
CONVERT_ARG_CHECKED(String, subject, 0);
@@ -4900,7 +5078,7 @@ static int CopyCachedAsciiCharsToArray(const char* chars,
// Converts a String to JSArray.
// For example, "foo" => ["f", "o", "o"].
-static Object* Runtime_StringToArray(Arguments args) {
+static MaybeObject* Runtime_StringToArray(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_ARG_CHECKED(String, s, 0);
@@ -4910,8 +5088,10 @@ static Object* Runtime_StringToArray(Arguments args) {
Handle<FixedArray> elements;
if (s->IsFlat() && s->IsAsciiRepresentation()) {
- Object* obj = Heap::AllocateUninitializedFixedArray(length);
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = Heap::AllocateUninitializedFixedArray(length);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
elements = Handle<FixedArray>(FixedArray::cast(obj));
Vector<const char> chars = s->ToAsciiVector();
@@ -4943,7 +5123,7 @@ static Object* Runtime_StringToArray(Arguments args) {
}
-static Object* Runtime_NewStringWrapper(Arguments args) {
+static MaybeObject* Runtime_NewStringWrapper(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(String, value, args[0]);
@@ -4958,7 +5138,7 @@ bool Runtime::IsUpperCaseChar(uint16_t ch) {
}
-static Object* Runtime_NumberToString(Arguments args) {
+static MaybeObject* Runtime_NumberToString(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4969,7 +5149,7 @@ static Object* Runtime_NumberToString(Arguments args) {
}
-static Object* Runtime_NumberToStringSkipCache(Arguments args) {
+static MaybeObject* Runtime_NumberToStringSkipCache(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4980,7 +5160,7 @@ static Object* Runtime_NumberToStringSkipCache(Arguments args) {
}
-static Object* Runtime_NumberToInteger(Arguments args) {
+static MaybeObject* Runtime_NumberToInteger(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -4994,7 +5174,7 @@ static Object* Runtime_NumberToInteger(Arguments args) {
}
-static Object* Runtime_NumberToIntegerMapMinusZero(Arguments args) {
+static MaybeObject* Runtime_NumberToIntegerMapMinusZero(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5013,7 +5193,7 @@ static Object* Runtime_NumberToIntegerMapMinusZero(Arguments args) {
}
-static Object* Runtime_NumberToJSUint32(Arguments args) {
+static MaybeObject* Runtime_NumberToJSUint32(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5022,7 +5202,7 @@ static Object* Runtime_NumberToJSUint32(Arguments args) {
}
-static Object* Runtime_NumberToJSInt32(Arguments args) {
+static MaybeObject* Runtime_NumberToJSInt32(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5038,7 +5218,7 @@ static Object* Runtime_NumberToJSInt32(Arguments args) {
// Converts a Number to a Smi, if possible. Returns NaN if the number is not
// a small integer.
-static Object* Runtime_NumberToSmi(Arguments args) {
+static MaybeObject* Runtime_NumberToSmi(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5057,7 +5237,7 @@ static Object* Runtime_NumberToSmi(Arguments args) {
}
-static Object* Runtime_NumberAdd(Arguments args) {
+static MaybeObject* Runtime_NumberAdd(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5067,7 +5247,7 @@ static Object* Runtime_NumberAdd(Arguments args) {
}
-static Object* Runtime_NumberSub(Arguments args) {
+static MaybeObject* Runtime_NumberSub(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5077,7 +5257,7 @@ static Object* Runtime_NumberSub(Arguments args) {
}
-static Object* Runtime_NumberMul(Arguments args) {
+static MaybeObject* Runtime_NumberMul(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5087,7 +5267,7 @@ static Object* Runtime_NumberMul(Arguments args) {
}
-static Object* Runtime_NumberUnaryMinus(Arguments args) {
+static MaybeObject* Runtime_NumberUnaryMinus(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5096,7 +5276,7 @@ static Object* Runtime_NumberUnaryMinus(Arguments args) {
}
-static Object* Runtime_NumberAlloc(Arguments args) {
+static MaybeObject* Runtime_NumberAlloc(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 0);
@@ -5104,7 +5284,7 @@ static Object* Runtime_NumberAlloc(Arguments args) {
}
-static Object* Runtime_NumberDiv(Arguments args) {
+static MaybeObject* Runtime_NumberDiv(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5114,7 +5294,7 @@ static Object* Runtime_NumberDiv(Arguments args) {
}
-static Object* Runtime_NumberMod(Arguments args) {
+static MaybeObject* Runtime_NumberMod(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5127,7 +5307,7 @@ static Object* Runtime_NumberMod(Arguments args) {
}
-static Object* Runtime_StringAdd(Arguments args) {
+static MaybeObject* Runtime_StringAdd(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
CONVERT_CHECKED(String, str1, args[0]);
@@ -5176,7 +5356,7 @@ static inline void StringBuilderConcatHelper(String* special,
}
-static Object* Runtime_StringBuilderConcat(Arguments args) {
+static MaybeObject* Runtime_StringBuilderConcat(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
CONVERT_CHECKED(JSArray, array, args[0]);
@@ -5264,8 +5444,9 @@ static Object* Runtime_StringBuilderConcat(Arguments args) {
Object* object;
if (ascii) {
- object = Heap::AllocateRawAsciiString(length);
- if (object->IsFailure()) return object;
+ { MaybeObject* maybe_object = Heap::AllocateRawAsciiString(length);
+ if (!maybe_object->ToObject(&object)) return maybe_object;
+ }
SeqAsciiString* answer = SeqAsciiString::cast(object);
StringBuilderConcatHelper(special,
answer->GetChars(),
@@ -5273,8 +5454,9 @@ static Object* Runtime_StringBuilderConcat(Arguments args) {
array_length);
return answer;
} else {
- object = Heap::AllocateRawTwoByteString(length);
- if (object->IsFailure()) return object;
+ { MaybeObject* maybe_object = Heap::AllocateRawTwoByteString(length);
+ if (!maybe_object->ToObject(&object)) return maybe_object;
+ }
SeqTwoByteString* answer = SeqTwoByteString::cast(object);
StringBuilderConcatHelper(special,
answer->GetChars(),
@@ -5285,7 +5467,7 @@ static Object* Runtime_StringBuilderConcat(Arguments args) {
}
-static Object* Runtime_NumberOr(Arguments args) {
+static MaybeObject* Runtime_NumberOr(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5295,7 +5477,7 @@ static Object* Runtime_NumberOr(Arguments args) {
}
-static Object* Runtime_NumberAnd(Arguments args) {
+static MaybeObject* Runtime_NumberAnd(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5305,7 +5487,7 @@ static Object* Runtime_NumberAnd(Arguments args) {
}
-static Object* Runtime_NumberXor(Arguments args) {
+static MaybeObject* Runtime_NumberXor(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5315,7 +5497,7 @@ static Object* Runtime_NumberXor(Arguments args) {
}
-static Object* Runtime_NumberNot(Arguments args) {
+static MaybeObject* Runtime_NumberNot(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -5324,7 +5506,7 @@ static Object* Runtime_NumberNot(Arguments args) {
}
-static Object* Runtime_NumberShl(Arguments args) {
+static MaybeObject* Runtime_NumberShl(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5334,7 +5516,7 @@ static Object* Runtime_NumberShl(Arguments args) {
}
-static Object* Runtime_NumberShr(Arguments args) {
+static MaybeObject* Runtime_NumberShr(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5344,7 +5526,7 @@ static Object* Runtime_NumberShr(Arguments args) {
}
-static Object* Runtime_NumberSar(Arguments args) {
+static MaybeObject* Runtime_NumberSar(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5354,7 +5536,7 @@ static Object* Runtime_NumberSar(Arguments args) {
}
-static Object* Runtime_NumberEquals(Arguments args) {
+static MaybeObject* Runtime_NumberEquals(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5373,7 +5555,7 @@ static Object* Runtime_NumberEquals(Arguments args) {
}
-static Object* Runtime_StringEquals(Arguments args) {
+static MaybeObject* Runtime_StringEquals(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5391,7 +5573,7 @@ static Object* Runtime_StringEquals(Arguments args) {
}
-static Object* Runtime_NumberCompare(Arguments args) {
+static MaybeObject* Runtime_NumberCompare(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
@@ -5406,7 +5588,7 @@ static Object* Runtime_NumberCompare(Arguments args) {
// Compare two Smis as if they were converted to strings and then
// compared lexicographically.
-static Object* Runtime_SmiLexicographicCompare(Arguments args) {
+static MaybeObject* Runtime_SmiLexicographicCompare(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5524,7 +5706,7 @@ static Object* FlatStringCompare(String* x, String* y) {
}
-static Object* Runtime_StringCompare(Arguments args) {
+static MaybeObject* Runtime_StringCompare(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -5546,17 +5728,20 @@ static Object* Runtime_StringCompare(Arguments args) {
if (d < 0) return Smi::FromInt(LESS);
else if (d > 0) return Smi::FromInt(GREATER);
- Object* obj = Heap::PrepareForCompare(x);
- if (obj->IsFailure()) return obj;
- obj = Heap::PrepareForCompare(y);
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = Heap::PrepareForCompare(x);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
+ { MaybeObject* maybe_obj = Heap::PrepareForCompare(y);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
return (x->IsFlat() && y->IsFlat()) ? FlatStringCompare(x, y)
: StringInputBufferCompare(x, y);
}
-static Object* Runtime_Math_acos(Arguments args) {
+static MaybeObject* Runtime_Math_acos(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_acos.Increment();
@@ -5566,7 +5751,7 @@ static Object* Runtime_Math_acos(Arguments args) {
}
-static Object* Runtime_Math_asin(Arguments args) {
+static MaybeObject* Runtime_Math_asin(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_asin.Increment();
@@ -5576,7 +5761,7 @@ static Object* Runtime_Math_asin(Arguments args) {
}
-static Object* Runtime_Math_atan(Arguments args) {
+static MaybeObject* Runtime_Math_atan(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_atan.Increment();
@@ -5586,7 +5771,7 @@ static Object* Runtime_Math_atan(Arguments args) {
}
-static Object* Runtime_Math_atan2(Arguments args) {
+static MaybeObject* Runtime_Math_atan2(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
Counters::math_atan2.Increment();
@@ -5610,7 +5795,7 @@ static Object* Runtime_Math_atan2(Arguments args) {
}
-static Object* Runtime_Math_ceil(Arguments args) {
+static MaybeObject* Runtime_Math_ceil(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_ceil.Increment();
@@ -5620,7 +5805,7 @@ static Object* Runtime_Math_ceil(Arguments args) {
}
-static Object* Runtime_Math_cos(Arguments args) {
+static MaybeObject* Runtime_Math_cos(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_cos.Increment();
@@ -5630,7 +5815,7 @@ static Object* Runtime_Math_cos(Arguments args) {
}
-static Object* Runtime_Math_exp(Arguments args) {
+static MaybeObject* Runtime_Math_exp(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_exp.Increment();
@@ -5640,7 +5825,7 @@ static Object* Runtime_Math_exp(Arguments args) {
}
-static Object* Runtime_Math_floor(Arguments args) {
+static MaybeObject* Runtime_Math_floor(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_floor.Increment();
@@ -5650,7 +5835,7 @@ static Object* Runtime_Math_floor(Arguments args) {
}
-static Object* Runtime_Math_log(Arguments args) {
+static MaybeObject* Runtime_Math_log(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_log.Increment();
@@ -5691,7 +5876,7 @@ static double powi(double x, int y) {
}
-static Object* Runtime_Math_pow(Arguments args) {
+static MaybeObject* Runtime_Math_pow(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
Counters::math_pow.Increment();
@@ -5731,7 +5916,7 @@ static Object* Runtime_Math_pow(Arguments args) {
// Fast version of Math.pow if we know that y is not an integer and
// y is not -0.5 or 0.5. Used as slowcase from codegen.
-static Object* Runtime_Math_pow_cfunction(Arguments args) {
+static MaybeObject* Runtime_Math_pow_cfunction(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
CONVERT_DOUBLE_CHECKED(x, args[0]);
@@ -5746,7 +5931,7 @@ static Object* Runtime_Math_pow_cfunction(Arguments args) {
}
-static Object* Runtime_RoundNumber(Arguments args) {
+static MaybeObject* Runtime_RoundNumber(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_round.Increment();
@@ -5782,7 +5967,7 @@ static Object* Runtime_RoundNumber(Arguments args) {
}
-static Object* Runtime_Math_sin(Arguments args) {
+static MaybeObject* Runtime_Math_sin(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_sin.Increment();
@@ -5792,7 +5977,7 @@ static Object* Runtime_Math_sin(Arguments args) {
}
-static Object* Runtime_Math_sqrt(Arguments args) {
+static MaybeObject* Runtime_Math_sqrt(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_sqrt.Increment();
@@ -5802,7 +5987,7 @@ static Object* Runtime_Math_sqrt(Arguments args) {
}
-static Object* Runtime_Math_tan(Arguments args) {
+static MaybeObject* Runtime_Math_tan(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_tan.Increment();
@@ -5857,7 +6042,7 @@ static int MakeDay(int year, int month, int day) {
}
-static Object* Runtime_DateMakeDay(Arguments args) {
+static MaybeObject* Runtime_DateMakeDay(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
@@ -6156,7 +6341,7 @@ static inline void DateYMDFromTime(int date,
}
-static Object* Runtime_DateYMDFromTime(Arguments args) {
+static MaybeObject* Runtime_DateYMDFromTime(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -6178,7 +6363,7 @@ static Object* Runtime_DateYMDFromTime(Arguments args) {
}
-static Object* Runtime_NewArgumentsFast(Arguments args) {
+static MaybeObject* Runtime_NewArgumentsFast(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 3);
@@ -6186,13 +6371,17 @@ static Object* Runtime_NewArgumentsFast(Arguments args) {
Object** parameters = reinterpret_cast<Object**>(args[1]);
const int length = Smi::cast(args[2])->value();
- Object* result = Heap::AllocateArgumentsObject(callee, length);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result = Heap::AllocateArgumentsObject(callee, length);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
// Allocate the elements if needed.
if (length > 0) {
// Allocate the fixed array.
- Object* obj = Heap::AllocateRawFixedArray(length);
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = Heap::AllocateRawFixedArray(length);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
AssertNoAllocation no_gc;
FixedArray* array = reinterpret_cast<FixedArray*>(obj);
@@ -6209,7 +6398,7 @@ static Object* Runtime_NewArgumentsFast(Arguments args) {
}
-static Object* Runtime_NewClosure(Arguments args) {
+static MaybeObject* Runtime_NewClosure(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(Context, context, 0);
@@ -6223,7 +6412,7 @@ static Object* Runtime_NewClosure(Arguments args) {
return *result;
}
-static Object* Runtime_NewObjectFromBound(Arguments args) {
+static MaybeObject* Runtime_NewObjectFromBound(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSFunction, function, 0);
@@ -6257,15 +6446,16 @@ static void TrySettingInlineConstructStub(Handle<JSFunction> function) {
}
if (function->shared()->CanGenerateInlineConstructor(*prototype)) {
ConstructStubCompiler compiler;
- Object* code = compiler.CompileConstructStub(function->shared());
+ MaybeObject* code = compiler.CompileConstructStub(function->shared());
if (!code->IsFailure()) {
- function->shared()->set_construct_stub(Code::cast(code));
+ function->shared()->set_construct_stub(
+ Code::cast(code->ToObjectUnchecked()));
}
}
}
-static Object* Runtime_NewObject(Arguments args) {
+static MaybeObject* Runtime_NewObject(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6341,7 +6531,7 @@ static Object* Runtime_NewObject(Arguments args) {
}
-static Object* Runtime_FinalizeInstanceSize(Arguments args) {
+static MaybeObject* Runtime_FinalizeInstanceSize(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6353,7 +6543,7 @@ static Object* Runtime_FinalizeInstanceSize(Arguments args) {
}
-static Object* Runtime_LazyCompile(Arguments args) {
+static MaybeObject* Runtime_LazyCompile(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6382,7 +6572,7 @@ static Object* Runtime_LazyCompile(Arguments args) {
}
-static Object* Runtime_GetFunctionDelegate(Arguments args) {
+static MaybeObject* Runtime_GetFunctionDelegate(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
RUNTIME_ASSERT(!args[0]->IsJSFunction());
@@ -6390,7 +6580,7 @@ static Object* Runtime_GetFunctionDelegate(Arguments args) {
}
-static Object* Runtime_GetConstructorDelegate(Arguments args) {
+static MaybeObject* Runtime_GetConstructorDelegate(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
RUNTIME_ASSERT(!args[0]->IsJSFunction());
@@ -6398,27 +6588,33 @@ static Object* Runtime_GetConstructorDelegate(Arguments args) {
}
-static Object* Runtime_NewContext(Arguments args) {
+static MaybeObject* Runtime_NewContext(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSFunction, function, args[0]);
int length = function->shared()->scope_info()->NumberOfContextSlots();
- Object* result = Heap::AllocateFunctionContext(length, function);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result = Heap::AllocateFunctionContext(length, function);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
Top::set_context(Context::cast(result));
return result; // non-failure
}
-static Object* PushContextHelper(Object* object, bool is_catch_context) {
+
+MUST_USE_RESULT static MaybeObject* PushContextHelper(Object* object,
+ bool is_catch_context) {
// Convert the object to a proper JavaScript object.
Object* js_object = object;
if (!js_object->IsJSObject()) {
- js_object = js_object->ToObject();
- if (js_object->IsFailure()) {
- if (!Failure::cast(js_object)->IsInternalError()) return js_object;
+ MaybeObject* maybe_js_object = js_object->ToObject();
+ if (!maybe_js_object->ToObject(&js_object)) {
+ if (!Failure::cast(maybe_js_object)->IsInternalError()) {
+ return maybe_js_object;
+ }
HandleScope scope;
Handle<Object> handle(object);
Handle<Object> result =
@@ -6427,11 +6623,13 @@ static Object* PushContextHelper(Object* object, bool is_catch_context) {
}
}
- Object* result =
- Heap::AllocateWithContext(Top::context(),
- JSObject::cast(js_object),
- is_catch_context);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result =
+ Heap::AllocateWithContext(Top::context(),
+ JSObject::cast(js_object),
+ is_catch_context);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
Context* context = Context::cast(result);
Top::set_context(context);
@@ -6440,21 +6638,21 @@ static Object* PushContextHelper(Object* object, bool is_catch_context) {
}
-static Object* Runtime_PushContext(Arguments args) {
+static MaybeObject* Runtime_PushContext(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
return PushContextHelper(args[0], false);
}
-static Object* Runtime_PushCatchContext(Arguments args) {
+static MaybeObject* Runtime_PushCatchContext(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
return PushContextHelper(args[0], true);
}
-static Object* Runtime_LookupContext(Arguments args) {
+static MaybeObject* Runtime_LookupContext(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -6487,11 +6685,11 @@ static Object* Runtime_LookupContext(Arguments args) {
// allocated by the caller, and passed as a pointer in a hidden first parameter.
#ifdef V8_HOST_ARCH_64_BIT
struct ObjectPair {
- Object* x;
- Object* y;
+ MaybeObject* x;
+ MaybeObject* y;
};
-static inline ObjectPair MakePair(Object* x, Object* y) {
+static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
ObjectPair result = {x, y};
// Pointers x and y returned in rax and rdx, in AMD-x64-abi.
// In Win64 they are assigned to a hidden first argument.
@@ -6499,14 +6697,15 @@ static inline ObjectPair MakePair(Object* x, Object* y) {
}
#else
typedef uint64_t ObjectPair;
-static inline ObjectPair MakePair(Object* x, Object* y) {
+static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) {
return reinterpret_cast<uint32_t>(x) |
(reinterpret_cast<ObjectPair>(y) << 32);
}
#endif
-static inline Object* Unhole(Object* x, PropertyAttributes attributes) {
+static inline MaybeObject* Unhole(MaybeObject* x,
+ PropertyAttributes attributes) {
ASSERT(!x->IsTheHole() || (attributes & READ_ONLY) != 0);
USE(attributes);
return x->IsTheHole() ? Heap::undefined_value() : x;
@@ -6556,7 +6755,7 @@ static ObjectPair LoadContextSlotHelper(Arguments args, bool throw_error) {
// argument in a context, the receiver is the global object; see
// ECMA-262, 3rd., 10.1.6 and 10.2.3.
JSObject* receiver = Top::context()->global()->global_receiver();
- Object* value = (holder->IsContext())
+ MaybeObject* value = (holder->IsContext())
? Context::cast(*holder)->get(index)
: JSObject::cast(*holder)->GetElement(index);
return MakePair(Unhole(value, attributes), receiver);
@@ -6576,7 +6775,7 @@ static ObjectPair LoadContextSlotHelper(Arguments args, bool throw_error) {
}
// No need to unhole the value here. This is taken care of by the
// GetProperty function.
- Object* value = object->GetProperty(*name);
+ MaybeObject* value = object->GetProperty(*name);
return MakePair(value, receiver);
}
@@ -6602,7 +6801,7 @@ static ObjectPair Runtime_LoadContextSlotNoReferenceError(Arguments args) {
}
-static Object* Runtime_StoreContextSlot(Arguments args) {
+static MaybeObject* Runtime_StoreContextSlot(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
@@ -6624,10 +6823,8 @@ static Object* Runtime_StoreContextSlot(Arguments args) {
}
} else {
ASSERT((attributes & READ_ONLY) == 0);
- Object* result =
- Handle<JSObject>::cast(holder)->SetElement(index, *value);
- USE(result);
- ASSERT(!result->IsFailure());
+ Handle<JSObject>::cast(holder)->SetElement(index, *value)->
+ ToObjectUnchecked();
}
return *value;
}
@@ -6663,7 +6860,7 @@ static Object* Runtime_StoreContextSlot(Arguments args) {
}
-static Object* Runtime_Throw(Arguments args) {
+static MaybeObject* Runtime_Throw(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6671,7 +6868,7 @@ static Object* Runtime_Throw(Arguments args) {
}
-static Object* Runtime_ReThrow(Arguments args) {
+static MaybeObject* Runtime_ReThrow(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6679,13 +6876,13 @@ static Object* Runtime_ReThrow(Arguments args) {
}
-static Object* Runtime_PromoteScheduledException(Arguments args) {
+static MaybeObject* Runtime_PromoteScheduledException(Arguments args) {
ASSERT_EQ(0, args.length());
return Top::PromoteScheduledException();
}
-static Object* Runtime_ThrowReferenceError(Arguments args) {
+static MaybeObject* Runtime_ThrowReferenceError(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -6696,13 +6893,13 @@ static Object* Runtime_ThrowReferenceError(Arguments args) {
}
-static Object* Runtime_StackOverflow(Arguments args) {
+static MaybeObject* Runtime_StackOverflow(Arguments args) {
NoHandleAllocation na;
return Top::StackOverflow();
}
-static Object* Runtime_StackGuard(Arguments args) {
+static MaybeObject* Runtime_StackGuard(Arguments args) {
ASSERT(args.length() == 0);
// First check if this is a real stack overflow.
@@ -6800,7 +6997,7 @@ static void PrintTransition(Object* result) {
}
-static Object* Runtime_TraceEnter(Arguments args) {
+static MaybeObject* Runtime_TraceEnter(Arguments args) {
ASSERT(args.length() == 0);
NoHandleAllocation ha;
PrintTransition(NULL);
@@ -6808,14 +7005,14 @@ static Object* Runtime_TraceEnter(Arguments args) {
}
-static Object* Runtime_TraceExit(Arguments args) {
+static MaybeObject* Runtime_TraceExit(Arguments args) {
NoHandleAllocation ha;
PrintTransition(args[0]);
return args[0]; // return TOS
}
-static Object* Runtime_DebugPrint(Arguments args) {
+static MaybeObject* Runtime_DebugPrint(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -6846,7 +7043,7 @@ static Object* Runtime_DebugPrint(Arguments args) {
}
-static Object* Runtime_DebugTrace(Arguments args) {
+static MaybeObject* Runtime_DebugTrace(Arguments args) {
ASSERT(args.length() == 0);
NoHandleAllocation ha;
Top::PrintStack();
@@ -6854,7 +7051,7 @@ static Object* Runtime_DebugTrace(Arguments args) {
}
-static Object* Runtime_DateCurrentTime(Arguments args) {
+static MaybeObject* Runtime_DateCurrentTime(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 0);
@@ -6867,7 +7064,7 @@ static Object* Runtime_DateCurrentTime(Arguments args) {
}
-static Object* Runtime_DateParseString(Arguments args) {
+static MaybeObject* Runtime_DateParseString(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -6897,7 +7094,7 @@ static Object* Runtime_DateParseString(Arguments args) {
}
-static Object* Runtime_DateLocalTimezone(Arguments args) {
+static MaybeObject* Runtime_DateLocalTimezone(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -6907,7 +7104,7 @@ static Object* Runtime_DateLocalTimezone(Arguments args) {
}
-static Object* Runtime_DateLocalTimeOffset(Arguments args) {
+static MaybeObject* Runtime_DateLocalTimeOffset(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 0);
@@ -6915,7 +7112,7 @@ static Object* Runtime_DateLocalTimeOffset(Arguments args) {
}
-static Object* Runtime_DateDaylightSavingsOffset(Arguments args) {
+static MaybeObject* Runtime_DateDaylightSavingsOffset(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -6924,7 +7121,7 @@ static Object* Runtime_DateDaylightSavingsOffset(Arguments args) {
}
-static Object* Runtime_GlobalReceiver(Arguments args) {
+static MaybeObject* Runtime_GlobalReceiver(Arguments args) {
ASSERT(args.length() == 1);
Object* global = args[0];
if (!global->IsJSGlobalObject()) return Heap::null_value();
@@ -6932,7 +7129,7 @@ static Object* Runtime_GlobalReceiver(Arguments args) {
}
-static Object* Runtime_CompileString(Arguments args) {
+static MaybeObject* Runtime_CompileString(Arguments args) {
HandleScope scope;
ASSERT_EQ(2, args.length());
CONVERT_ARG_CHECKED(String, source, 0);
@@ -7060,7 +7257,7 @@ static ObjectPair Runtime_ResolvePossiblyDirectEvalNoLookup(Arguments args) {
}
-static Object* Runtime_SetNewFunctionAttributes(Arguments args) {
+static MaybeObject* Runtime_SetNewFunctionAttributes(Arguments args) {
// This utility adjusts the property attributes for newly created Function
// object ("new Function(...)") by changing the map.
// All it does is changing the prototype property to enumerable
@@ -7077,7 +7274,7 @@ static Object* Runtime_SetNewFunctionAttributes(Arguments args) {
}
-static Object* Runtime_AllocateInNewSpace(Arguments args) {
+static MaybeObject* Runtime_AllocateInNewSpace(Arguments args) {
// Allocate a block of memory in NewSpace (filled with a filler).
// Use as fallback for allocation in generated code when NewSpace
// is full.
@@ -7089,18 +7286,20 @@ static Object* Runtime_AllocateInNewSpace(Arguments args) {
static const int kMinFreeNewSpaceAfterGC =
Heap::InitialSemiSpaceSize() * 3/4;
RUNTIME_ASSERT(size <= kMinFreeNewSpaceAfterGC);
- Object* allocation = Heap::new_space()->AllocateRaw(size);
- if (!allocation->IsFailure()) {
- Heap::CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
+ Object* allocation;
+ { MaybeObject* maybe_allocation = Heap::new_space()->AllocateRaw(size);
+ if (maybe_allocation->ToObject(&allocation)) {
+ Heap::CreateFillerObjectAt(HeapObject::cast(allocation)->address(), size);
+ }
+ return maybe_allocation;
}
- return allocation;
}
// Push an array unto an array of arrays if it is not already in the
// array. Returns true if the element was pushed on the stack and
// false otherwise.
-static Object* Runtime_PushIfAbsent(Arguments args) {
+static MaybeObject* Runtime_PushIfAbsent(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSArray, array, args[0]);
CONVERT_CHECKED(JSArray, element, args[1]);
@@ -7110,8 +7309,10 @@ static Object* Runtime_PushIfAbsent(Arguments args) {
for (int i = 0; i < length; i++) {
if (elements->get(i) == element) return Heap::false_value();
}
- Object* obj = array->SetFastElement(length, element);
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = array->SetFastElement(length, element);
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
return Heap::true_value();
}
@@ -7405,30 +7606,36 @@ static uint32_t IterateArguments(Handle<JSArray> arguments,
uint32_t num_of_args = static_cast<uint32_t>(arguments->length()->Number());
for (uint32_t i = 0; i < num_of_args; i++) {
- Handle<Object> obj(arguments->GetElement(i));
- if (obj->IsJSArray()) {
- Handle<JSArray> array = Handle<JSArray>::cast(obj);
- uint32_t len = static_cast<uint32_t>(array->length()->Number());
- uint32_t nof_elements =
- IterateArrayAndPrototypeElements(array, visitor);
- // Total elements of array and its prototype chain can be more than
- // the array length, but ArrayConcat can only concatenate at most
- // the array length number of elements. We use the length as an estimate
- // for the actual number of elements added.
- uint32_t added_elements = (nof_elements > len) ? len : nof_elements;
- if (JSArray::kMaxElementCount - visited_elements < added_elements) {
- visited_elements = JSArray::kMaxElementCount;
+ Object *element;
+ MaybeObject* maybe_element = arguments->GetElement(i);
+ // This if() is not expected to fail, but we have the check in the
+ // interest of hardening the runtime calls.
+ if (maybe_element->ToObject(&element)) {
+ Handle<Object> obj(element);
+ if (obj->IsJSArray()) {
+ Handle<JSArray> array = Handle<JSArray>::cast(obj);
+ uint32_t len = static_cast<uint32_t>(array->length()->Number());
+ uint32_t nof_elements =
+ IterateArrayAndPrototypeElements(array, visitor);
+ // Total elements of array and its prototype chain can be more than
+ // the array length, but ArrayConcat can only concatenate at most
+ // the array length number of elements. We use the length as an estimate
+ // for the actual number of elements added.
+ uint32_t added_elements = (nof_elements > len) ? len : nof_elements;
+ if (JSArray::kMaxElementCount - visited_elements < added_elements) {
+ visited_elements = JSArray::kMaxElementCount;
+ } else {
+ visited_elements += added_elements;
+ }
+ if (visitor) visitor->increase_index_offset(len);
} else {
- visited_elements += added_elements;
- }
- if (visitor) visitor->increase_index_offset(len);
- } else {
- if (visitor) {
- visitor->visit(0, obj);
- visitor->increase_index_offset(1);
- }
- if (visited_elements < JSArray::kMaxElementCount) {
- visited_elements++;
+ if (visitor) {
+ visitor->visit(0, obj);
+ visitor->increase_index_offset(1);
+ }
+ if (visited_elements < JSArray::kMaxElementCount) {
+ visited_elements++;
+ }
}
}
}
@@ -7442,7 +7649,7 @@ static uint32_t IterateArguments(Handle<JSArray> arguments,
* TODO(lrn): Fix non-compliance for very large concatenations and update to
* following the ECMAScript 5 specification.
*/
-static Object* Runtime_ArrayConcat(Arguments args) {
+static MaybeObject* Runtime_ArrayConcat(Arguments args) {
ASSERT(args.length() == 1);
HandleScope handle_scope;
@@ -7456,19 +7663,24 @@ static Object* Runtime_ArrayConcat(Arguments args) {
{ AssertNoAllocation nogc;
for (uint32_t i = 0; i < num_of_args; i++) {
- Object* obj = arguments->GetElement(i);
- uint32_t length_estimate;
- if (obj->IsJSArray()) {
- length_estimate =
- static_cast<uint32_t>(JSArray::cast(obj)->length()->Number());
- } else {
- length_estimate = 1;
- }
- if (JSObject::kMaxElementCount - result_length < length_estimate) {
- result_length = JSObject::kMaxElementCount;
- break;
+ Object* obj;
+ MaybeObject* maybe_object = arguments->GetElement(i);
+ // This if() is not expected to fail, but we have the check in the
+ // interest of hardening the runtime calls.
+ if (maybe_object->ToObject(&obj)) {
+ uint32_t length_estimate;
+ if (obj->IsJSArray()) {
+ length_estimate =
+ static_cast<uint32_t>(JSArray::cast(obj)->length()->Number());
+ } else {
+ length_estimate = 1;
+ }
+ if (JSObject::kMaxElementCount - result_length < length_estimate) {
+ result_length = JSObject::kMaxElementCount;
+ break;
+ }
+ result_length += length_estimate;
}
- result_length += length_estimate;
}
}
@@ -7516,7 +7728,7 @@ static Object* Runtime_ArrayConcat(Arguments args) {
// This will not allocate (flatten the string), but it may run
// very slowly for very deeply nested ConsStrings. For debugging use only.
-static Object* Runtime_GlobalPrint(Arguments args) {
+static MaybeObject* Runtime_GlobalPrint(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -7534,7 +7746,7 @@ static Object* Runtime_GlobalPrint(Arguments args) {
// and are followed by non-existing element. Does not change the length
// property.
// Returns the number of non-undefined elements collected.
-static Object* Runtime_RemoveArrayHoles(Arguments args) {
+static MaybeObject* Runtime_RemoveArrayHoles(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSObject, object, args[0]);
CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
@@ -7543,31 +7755,34 @@ static Object* Runtime_RemoveArrayHoles(Arguments args) {
// Move contents of argument 0 (an array) to argument 1 (an array)
-static Object* Runtime_MoveArrayContents(Arguments args) {
+static MaybeObject* Runtime_MoveArrayContents(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(JSArray, from, args[0]);
CONVERT_CHECKED(JSArray, to, args[1]);
HeapObject* new_elements = from->elements();
- Object* new_map;
+ MaybeObject* maybe_new_map;
if (new_elements->map() == Heap::fixed_array_map() ||
new_elements->map() == Heap::fixed_cow_array_map()) {
- new_map = to->map()->GetFastElementsMap();
+ maybe_new_map = to->map()->GetFastElementsMap();
} else {
- new_map = to->map()->GetSlowElementsMap();
+ maybe_new_map = to->map()->GetSlowElementsMap();
}
- if (new_map->IsFailure()) return new_map;
+ Object* new_map;
+ if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
to->set_map(Map::cast(new_map));
to->set_elements(new_elements);
to->set_length(from->length());
- Object* obj = from->ResetElements();
- if (obj->IsFailure()) return obj;
+ Object* obj;
+ { MaybeObject* maybe_obj = from->ResetElements();
+ if (!maybe_obj->ToObject(&obj)) return maybe_obj;
+ }
from->set_length(Smi::FromInt(0));
return to;
}
// How many elements does this object/array have?
-static Object* Runtime_EstimateNumberOfElements(Arguments args) {
+static MaybeObject* Runtime_EstimateNumberOfElements(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSObject, object, args[0]);
HeapObject* elements = object->elements();
@@ -7581,7 +7796,7 @@ static Object* Runtime_EstimateNumberOfElements(Arguments args) {
}
-static Object* Runtime_SwapElements(Arguments args) {
+static MaybeObject* Runtime_SwapElements(Arguments args) {
HandleScope handle_scope;
ASSERT_EQ(3, args.length());
@@ -7612,7 +7827,7 @@ static Object* Runtime_SwapElements(Arguments args) {
// intervals (pair of a negative integer (-start-1) followed by a
// positive (length)) or undefined values.
// Intervals can span over some keys that are not in the object.
-static Object* Runtime_GetArrayKeys(Arguments args) {
+static MaybeObject* Runtime_GetArrayKeys(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSObject, array, 0);
@@ -7652,7 +7867,7 @@ static Object* Runtime_GetArrayKeys(Arguments args) {
// to the way accessors are implemented, it is set for both the getter
// and setter on the first call to DefineAccessor and ignored on
// subsequent calls.
-static Object* Runtime_DefineAccessor(Arguments args) {
+static MaybeObject* Runtime_DefineAccessor(Arguments args) {
RUNTIME_ASSERT(args.length() == 4 || args.length() == 5);
// Compute attributes.
PropertyAttributes attributes = NONE;
@@ -7672,7 +7887,7 @@ static Object* Runtime_DefineAccessor(Arguments args) {
}
-static Object* Runtime_LookupAccessor(Arguments args) {
+static MaybeObject* Runtime_LookupAccessor(Arguments args) {
ASSERT(args.length() == 3);
CONVERT_CHECKED(JSObject, obj, args[0]);
CONVERT_CHECKED(String, name, args[1]);
@@ -7682,7 +7897,7 @@ static Object* Runtime_LookupAccessor(Arguments args) {
#ifdef ENABLE_DEBUGGER_SUPPORT
-static Object* Runtime_DebugBreak(Arguments args) {
+static MaybeObject* Runtime_DebugBreak(Arguments args) {
ASSERT(args.length() == 0);
return Execution::DebugBreakHelper();
}
@@ -7704,7 +7919,7 @@ static StackFrame::Id UnwrapFrameId(Smi* wrapped) {
// args[0]: debug event listener function to set or null or undefined for
// clearing the event listener function
// args[1]: object supplied during callback
-static Object* Runtime_SetDebugEventListener(Arguments args) {
+static MaybeObject* Runtime_SetDebugEventListener(Arguments args) {
ASSERT(args.length() == 2);
RUNTIME_ASSERT(args[0]->IsJSFunction() ||
args[0]->IsUndefined() ||
@@ -7717,16 +7932,16 @@ static Object* Runtime_SetDebugEventListener(Arguments args) {
}
-static Object* Runtime_Break(Arguments args) {
+static MaybeObject* Runtime_Break(Arguments args) {
ASSERT(args.length() == 0);
StackGuard::DebugBreak();
return Heap::undefined_value();
}
-static Object* DebugLookupResultValue(Object* receiver, String* name,
- LookupResult* result,
- bool* caught_exception) {
+static MaybeObject* DebugLookupResultValue(Object* receiver, String* name,
+ LookupResult* result,
+ bool* caught_exception) {
Object* value;
switch (result->type()) {
case NORMAL:
@@ -7748,14 +7963,16 @@ static Object* DebugLookupResultValue(Object* receiver, String* name,
case CALLBACKS: {
Object* structure = result->GetCallbackObject();
if (structure->IsProxy() || structure->IsAccessorInfo()) {
- value = receiver->GetPropertyWithCallback(
+ MaybeObject* maybe_value = receiver->GetPropertyWithCallback(
receiver, structure, name, result->holder());
- if (value->IsException()) {
- value = Top::pending_exception();
+ if (!maybe_value->ToObject(&value)) {
+ ASSERT(maybe_value->IsException());
+ maybe_value = Top::pending_exception();
Top::clear_pending_exception();
if (caught_exception != NULL) {
*caught_exception = true;
}
+ return maybe_value;
}
return value;
} else {
@@ -7787,7 +8004,7 @@ static Object* DebugLookupResultValue(Object* receiver, String* name,
// 4: Setter function if defined
// Items 2-4 are only filled if the property has either a getter or a setter
// defined through __defineGetter__ and/or __defineSetter__.
-static Object* Runtime_DebugGetPropertyDetails(Arguments args) {
+static MaybeObject* Runtime_DebugGetPropertyDetails(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -7818,7 +8035,13 @@ static Object* Runtime_DebugGetPropertyDetails(Arguments args) {
uint32_t index;
if (name->AsArrayIndex(&index)) {
Handle<FixedArray> details = Factory::NewFixedArray(2);
- Object* element_or_char = Runtime::GetElementOrCharAt(obj, index);
+ Object* element_or_char;
+ { MaybeObject* maybe_element_or_char =
+ Runtime::GetElementOrCharAt(obj, index);
+ if (!maybe_element_or_char->ToObject(&element_or_char)) {
+ return maybe_element_or_char;
+ }
+ }
details->set(0, element_or_char);
details->set(1, PropertyDetails(NONE, NORMAL).AsSmi());
return *Factory::NewJSArrayWithElements(details);
@@ -7845,9 +8068,11 @@ static Object* Runtime_DebugGetPropertyDetails(Arguments args) {
// DebugLookupResultValue can cause GC so details from LookupResult needs
// to be copied to handles before this.
bool caught_exception = false;
- Object* raw_value = DebugLookupResultValue(*obj, *name, &result,
- &caught_exception);
- if (raw_value->IsFailure()) return raw_value;
+ Object* raw_value;
+ { MaybeObject* maybe_raw_value =
+ DebugLookupResultValue(*obj, *name, &result, &caught_exception);
+ if (!maybe_raw_value->ToObject(&raw_value)) return maybe_raw_value;
+ }
Handle<Object> value(raw_value);
// If the callback object is a fixed array then it contains JavaScript
@@ -7877,7 +8102,7 @@ static Object* Runtime_DebugGetPropertyDetails(Arguments args) {
}
-static Object* Runtime_DebugGetProperty(Arguments args) {
+static MaybeObject* Runtime_DebugGetProperty(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
@@ -7896,7 +8121,7 @@ static Object* Runtime_DebugGetProperty(Arguments args) {
// Return the property type calculated from the property details.
// args[0]: smi with property details.
-static Object* Runtime_DebugPropertyTypeFromDetails(Arguments args) {
+static MaybeObject* Runtime_DebugPropertyTypeFromDetails(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(Smi, details, args[0]);
PropertyType type = PropertyDetails(details).type();
@@ -7906,7 +8131,7 @@ static Object* Runtime_DebugPropertyTypeFromDetails(Arguments args) {
// Return the property attribute calculated from the property details.
// args[0]: smi with property details.
-static Object* Runtime_DebugPropertyAttributesFromDetails(Arguments args) {
+static MaybeObject* Runtime_DebugPropertyAttributesFromDetails(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(Smi, details, args[0]);
PropertyAttributes attributes = PropertyDetails(details).attributes();
@@ -7916,7 +8141,7 @@ static Object* Runtime_DebugPropertyAttributesFromDetails(Arguments args) {
// Return the property insertion index calculated from the property details.
// args[0]: smi with property details.
-static Object* Runtime_DebugPropertyIndexFromDetails(Arguments args) {
+static MaybeObject* Runtime_DebugPropertyIndexFromDetails(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(Smi, details, args[0]);
int index = PropertyDetails(details).index();
@@ -7927,7 +8152,7 @@ static Object* Runtime_DebugPropertyIndexFromDetails(Arguments args) {
// Return property value from named interceptor.
// args[0]: object
// args[1]: property name
-static Object* Runtime_DebugNamedInterceptorPropertyValue(Arguments args) {
+static MaybeObject* Runtime_DebugNamedInterceptorPropertyValue(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -7942,7 +8167,8 @@ static Object* Runtime_DebugNamedInterceptorPropertyValue(Arguments args) {
// Return element value from indexed interceptor.
// args[0]: object
// args[1]: index
-static Object* Runtime_DebugIndexedInterceptorElementValue(Arguments args) {
+static MaybeObject* Runtime_DebugIndexedInterceptorElementValue(
+ Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
CONVERT_ARG_CHECKED(JSObject, obj, 0);
@@ -7953,7 +8179,7 @@ static Object* Runtime_DebugIndexedInterceptorElementValue(Arguments args) {
}
-static Object* Runtime_CheckExecutionState(Arguments args) {
+static MaybeObject* Runtime_CheckExecutionState(Arguments args) {
ASSERT(args.length() >= 1);
CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
// Check that the break id is valid.
@@ -7965,13 +8191,15 @@ static Object* Runtime_CheckExecutionState(Arguments args) {
}
-static Object* Runtime_GetFrameCount(Arguments args) {
+static MaybeObject* Runtime_GetFrameCount(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
// Check arguments.
- Object* result = Runtime_CheckExecutionState(args);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result = Runtime_CheckExecutionState(args);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
// Count all frames which are relevant to debugging stack trace.
int n = 0;
@@ -8013,13 +8241,15 @@ static const int kFrameDetailsFirstDynamicIndex = 9;
// Arguments name, value
// Locals name, value
// Return value if any
-static Object* Runtime_GetFrameDetails(Arguments args) {
+static MaybeObject* Runtime_GetFrameDetails(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
// Check arguments.
- Object* check = Runtime_CheckExecutionState(args);
- if (check->IsFailure()) return check;
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
// Find the relevant frame with the requested index.
@@ -8320,9 +8550,12 @@ static Handle<JSObject> MaterializeClosure(Handle<Context> context) {
Handle<JSObject> arguments_shadow(
JSObject::cast(context->get(arguments_shadow_index)));
for (int i = 0; i < scope_info.number_of_parameters(); ++i) {
+ // We don't expect exception-throwing getters on the arguments shadow.
+ Object* element = arguments_shadow->GetElement(i)->ToObjectUnchecked();
SetProperty(closure_scope,
scope_info.parameter_name(i),
- Handle<Object>(arguments_shadow->GetElement(i)), NONE);
+ Handle<Object>(element),
+ NONE);
}
}
@@ -8554,13 +8787,15 @@ class ScopeIterator {
};
-static Object* Runtime_GetScopeCount(Arguments args) {
+static MaybeObject* Runtime_GetScopeCount(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
// Check arguments.
- Object* check = Runtime_CheckExecutionState(args);
- if (check->IsFailure()) return check;
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
CONVERT_CHECKED(Smi, wrapped_id, args[1]);
// Get the frame where the debugging is performed.
@@ -8590,13 +8825,15 @@ static const int kScopeDetailsSize = 2;
// The array returned contains the following information:
// 0: Scope type
// 1: Scope object
-static Object* Runtime_GetScopeDetails(Arguments args) {
+static MaybeObject* Runtime_GetScopeDetails(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
// Check arguments.
- Object* check = Runtime_CheckExecutionState(args);
- if (check->IsFailure()) return check;
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
CONVERT_CHECKED(Smi, wrapped_id, args[1]);
CONVERT_NUMBER_CHECKED(int, index, Int32, args[2]);
@@ -8628,7 +8865,7 @@ static Object* Runtime_GetScopeDetails(Arguments args) {
}
-static Object* Runtime_DebugPrintScopes(Arguments args) {
+static MaybeObject* Runtime_DebugPrintScopes(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 0);
@@ -8644,60 +8881,21 @@ static Object* Runtime_DebugPrintScopes(Arguments args) {
}
-static Object* Runtime_GetCFrames(Arguments args) {
- HandleScope scope;
- ASSERT(args.length() == 1);
- Object* result = Runtime_CheckExecutionState(args);
- if (result->IsFailure()) return result;
-
-#if V8_HOST_ARCH_64_BIT
- UNIMPLEMENTED();
+static MaybeObject* Runtime_GetCFrames(Arguments args) {
+ // See bug 906.
return Heap::undefined_value();
-#else
-
- static const int kMaxCFramesSize = 200;
- ScopedVector<OS::StackFrame> frames(kMaxCFramesSize);
- int frames_count = OS::StackWalk(frames);
- if (frames_count == OS::kStackWalkError) {
- return Heap::undefined_value();
- }
-
- Handle<String> address_str = Factory::LookupAsciiSymbol("address");
- Handle<String> text_str = Factory::LookupAsciiSymbol("text");
- Handle<FixedArray> frames_array = Factory::NewFixedArray(frames_count);
- for (int i = 0; i < frames_count; i++) {
- Handle<JSObject> frame_value = Factory::NewJSObject(Top::object_function());
- Handle<Object> frame_address =
- Factory::NewNumberFromInt(reinterpret_cast<int>(frames[i].address));
-
- frame_value->SetProperty(*address_str, *frame_address, NONE);
-
- // Get the stack walk text for this frame.
- Handle<String> frame_text;
- int frame_text_length = StrLength(frames[i].text);
- if (frame_text_length > 0) {
- Vector<const char> str(frames[i].text, frame_text_length);
- frame_text = Factory::NewStringFromAscii(str);
- }
-
- if (!frame_text.is_null()) {
- frame_value->SetProperty(*text_str, *frame_text, NONE);
- }
-
- frames_array->set(i, *frame_value);
- }
- return *Factory::NewJSArrayWithElements(frames_array);
-#endif // V8_HOST_ARCH_64_BIT
}
-static Object* Runtime_GetThreadCount(Arguments args) {
+static MaybeObject* Runtime_GetThreadCount(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
// Check arguments.
- Object* result = Runtime_CheckExecutionState(args);
- if (result->IsFailure()) return result;
+ Object* result;
+ { MaybeObject* maybe_result = Runtime_CheckExecutionState(args);
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
// Count all archived V8 threads.
int n = 0;
@@ -8723,13 +8921,15 @@ static const int kThreadDetailsSize = 2;
// The array returned contains the following information:
// 0: Is current thread?
// 1: Thread id
-static Object* Runtime_GetThreadDetails(Arguments args) {
+static MaybeObject* Runtime_GetThreadDetails(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
// Check arguments.
- Object* check = Runtime_CheckExecutionState(args);
- if (check->IsFailure()) return check;
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]);
// Allocate array for result.
@@ -8765,7 +8965,7 @@ static Object* Runtime_GetThreadDetails(Arguments args) {
// Sets the disable break state
// args[0]: disable break state
-static Object* Runtime_SetDisableBreak(Arguments args) {
+static MaybeObject* Runtime_SetDisableBreak(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
CONVERT_BOOLEAN_CHECKED(disable_break, args[0]);
@@ -8774,7 +8974,7 @@ static Object* Runtime_SetDisableBreak(Arguments args) {
}
-static Object* Runtime_GetBreakLocations(Arguments args) {
+static MaybeObject* Runtime_GetBreakLocations(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -8793,7 +8993,7 @@ static Object* Runtime_GetBreakLocations(Arguments args) {
// args[0]: function
// args[1]: number: break source position (within the function source)
// args[2]: number: break point object
-static Object* Runtime_SetFunctionBreakPoint(Arguments args) {
+static MaybeObject* Runtime_SetFunctionBreakPoint(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(JSFunction, fun, 0);
@@ -8892,7 +9092,7 @@ Object* Runtime::FindSharedFunctionInfoInScript(Handle<Script> script,
// args[0]: script to set break point in
// args[1]: number: break source position (within the script source)
// args[2]: number: break point object
-static Object* Runtime_SetScriptBreakPoint(Arguments args) {
+static MaybeObject* Runtime_SetScriptBreakPoint(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
CONVERT_ARG_CHECKED(JSValue, wrapper, 0);
@@ -8926,7 +9126,7 @@ static Object* Runtime_SetScriptBreakPoint(Arguments args) {
// Clear a break point
// args[0]: number: break point object
-static Object* Runtime_ClearBreakPoint(Arguments args) {
+static MaybeObject* Runtime_ClearBreakPoint(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
Handle<Object> break_point_object_arg = args.at<Object>(0);
@@ -8941,7 +9141,7 @@ static Object* Runtime_ClearBreakPoint(Arguments args) {
// Change the state of break on exceptions.
// args[0]: Enum value indicating whether to affect caught/uncaught exceptions.
// args[1]: Boolean indicating on/off.
-static Object* Runtime_ChangeBreakOnException(Arguments args) {
+static MaybeObject* Runtime_ChangeBreakOnException(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 2);
RUNTIME_ASSERT(args[0]->IsNumber());
@@ -8959,7 +9159,7 @@ static Object* Runtime_ChangeBreakOnException(Arguments args) {
// Returns the state of break on exceptions
// args[0]: boolean indicating uncaught exceptions
-static Object* Runtime_IsBreakOnException(Arguments args) {
+static MaybeObject* Runtime_IsBreakOnException(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
RUNTIME_ASSERT(args[0]->IsNumber());
@@ -8976,12 +9176,14 @@ static Object* Runtime_IsBreakOnException(Arguments args) {
// args[1]: step action from the enumeration StepAction
// args[2]: number of times to perform the step, for step out it is the number
// of frames to step down.
-static Object* Runtime_PrepareStep(Arguments args) {
+static MaybeObject* Runtime_PrepareStep(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 3);
// Check arguments.
- Object* check = Runtime_CheckExecutionState(args);
- if (check->IsFailure()) return check;
+ Object* check;
+ { MaybeObject* maybe_check = Runtime_CheckExecutionState(args);
+ if (!maybe_check->ToObject(&check)) return maybe_check;
+ }
if (!args[1]->IsNumber() || !args[2]->IsNumber()) {
return Top::Throw(Heap::illegal_argument_symbol());
}
@@ -9012,7 +9214,7 @@ static Object* Runtime_PrepareStep(Arguments args) {
// Clear all stepping set by PrepareStep.
-static Object* Runtime_ClearStepping(Arguments args) {
+static MaybeObject* Runtime_ClearStepping(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 0);
Debug::ClearStepping();
@@ -9089,14 +9291,18 @@ static Handle<Object> GetArgumentsObject(JavaScriptFrame* frame,
// stack frame presenting the same view of the values of parameters and
// local variables as if the piece of JavaScript was evaluated at the point
// where the function on the stack frame is currently stopped.
-static Object* Runtime_DebugEvaluate(Arguments args) {
+static MaybeObject* Runtime_DebugEvaluate(Arguments args) {
HandleScope scope;
// Check the execution state and decode arguments frame and source to be
// evaluated.
ASSERT(args.length() == 4);
- Object* check_result = Runtime_CheckExecutionState(args);
- if (check_result->IsFailure()) return check_result;
+ Object* check_result;
+ { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args);
+ if (!maybe_check_result->ToObject(&check_result)) {
+ return maybe_check_result;
+ }
+ }
CONVERT_CHECKED(Smi, wrapped_id, args[1]);
CONVERT_ARG_CHECKED(String, source, 2);
CONVERT_BOOLEAN_CHECKED(disable_break, args[3]);
@@ -9200,14 +9406,18 @@ static Object* Runtime_DebugEvaluate(Arguments args) {
}
-static Object* Runtime_DebugEvaluateGlobal(Arguments args) {
+static MaybeObject* Runtime_DebugEvaluateGlobal(Arguments args) {
HandleScope scope;
// Check the execution state and decode arguments frame and source to be
// evaluated.
ASSERT(args.length() == 3);
- Object* check_result = Runtime_CheckExecutionState(args);
- if (check_result->IsFailure()) return check_result;
+ Object* check_result;
+ { MaybeObject* maybe_check_result = Runtime_CheckExecutionState(args);
+ if (!maybe_check_result->ToObject(&check_result)) {
+ return maybe_check_result;
+ }
+ }
CONVERT_ARG_CHECKED(String, source, 1);
CONVERT_BOOLEAN_CHECKED(disable_break, args[2]);
@@ -9250,7 +9460,7 @@ static Object* Runtime_DebugEvaluateGlobal(Arguments args) {
}
-static Object* Runtime_DebugGetLoadedScripts(Arguments args) {
+static MaybeObject* Runtime_DebugGetLoadedScripts(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 0);
@@ -9350,7 +9560,7 @@ static int DebugReferencedBy(JSObject* target,
// args[0]: the object to find references to
// args[1]: constructor function for instances to exclude (Mirror)
// args[2]: the the maximum number of objects to return
-static Object* Runtime_DebugReferencedBy(Arguments args) {
+static MaybeObject* Runtime_DebugReferencedBy(Arguments args) {
ASSERT(args.length() == 3);
// First perform a full GC in order to avoid references from dead objects.
@@ -9376,8 +9586,10 @@ static Object* Runtime_DebugReferencedBy(Arguments args) {
NULL, 0, arguments_function);
// Allocate an array to hold the result.
- Object* object = Heap::AllocateFixedArray(count);
- if (object->IsFailure()) return object;
+ Object* object;
+ { MaybeObject* maybe_object = Heap::AllocateFixedArray(count);
+ if (!maybe_object->ToObject(&object)) return maybe_object;
+ }
FixedArray* instances = FixedArray::cast(object);
// Fill the referencing objects.
@@ -9385,10 +9597,12 @@ static Object* Runtime_DebugReferencedBy(Arguments args) {
instances, count, arguments_function);
// Return result as JS array.
- Object* result =
- Heap::AllocateJSObject(
- Top::context()->global_context()->array_function());
- if (!result->IsFailure()) JSArray::cast(result)->SetContent(instances);
+ Object* result;
+ { MaybeObject* maybe_result = Heap::AllocateJSObject(
+ Top::context()->global_context()->array_function());
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
+ JSArray::cast(result)->SetContent(instances);
return result;
}
@@ -9426,7 +9640,7 @@ static int DebugConstructedBy(JSFunction* constructor, int max_references,
// Scan the heap for objects constructed by a specific function.
// args[0]: the constructor to find instances of
// args[1]: the the maximum number of objects to return
-static Object* Runtime_DebugConstructedBy(Arguments args) {
+static MaybeObject* Runtime_DebugConstructedBy(Arguments args) {
ASSERT(args.length() == 2);
// First perform a full GC in order to avoid dead objects.
@@ -9442,25 +9656,29 @@ static Object* Runtime_DebugConstructedBy(Arguments args) {
count = DebugConstructedBy(constructor, max_references, NULL, 0);
// Allocate an array to hold the result.
- Object* object = Heap::AllocateFixedArray(count);
- if (object->IsFailure()) return object;
+ Object* object;
+ { MaybeObject* maybe_object = Heap::AllocateFixedArray(count);
+ if (!maybe_object->ToObject(&object)) return maybe_object;
+ }
FixedArray* instances = FixedArray::cast(object);
// Fill the referencing objects.
count = DebugConstructedBy(constructor, max_references, instances, count);
// Return result as JS array.
- Object* result =
- Heap::AllocateJSObject(
- Top::context()->global_context()->array_function());
- if (!result->IsFailure()) JSArray::cast(result)->SetContent(instances);
+ Object* result;
+ { MaybeObject* maybe_result = Heap::AllocateJSObject(
+ Top::context()->global_context()->array_function());
+ if (!maybe_result->ToObject(&result)) return maybe_result;
+ }
+ JSArray::cast(result)->SetContent(instances);
return result;
}
// Find the effective prototype object as returned by __proto__.
// args[0]: the object to find the prototype for.
-static Object* Runtime_DebugGetPrototype(Arguments args) {
+static MaybeObject* Runtime_DebugGetPrototype(Arguments args) {
ASSERT(args.length() == 1);
CONVERT_CHECKED(JSObject, obj, args[0]);
@@ -9470,14 +9688,14 @@ static Object* Runtime_DebugGetPrototype(Arguments args) {
}
-static Object* Runtime_SystemBreak(Arguments args) {
+static MaybeObject* Runtime_SystemBreak(Arguments args) {
ASSERT(args.length() == 0);
CPU::DebugBreak();
return Heap::undefined_value();
}
-static Object* Runtime_DebugDisassembleFunction(Arguments args) {
+static MaybeObject* Runtime_DebugDisassembleFunction(Arguments args) {
#ifdef DEBUG
HandleScope scope;
ASSERT(args.length() == 1);
@@ -9493,7 +9711,7 @@ static Object* Runtime_DebugDisassembleFunction(Arguments args) {
}
-static Object* Runtime_DebugDisassembleConstructor(Arguments args) {
+static MaybeObject* Runtime_DebugDisassembleConstructor(Arguments args) {
#ifdef DEBUG
HandleScope scope;
ASSERT(args.length() == 1);
@@ -9509,7 +9727,7 @@ static Object* Runtime_DebugDisassembleConstructor(Arguments args) {
}
-static Object* Runtime_FunctionGetInferredName(Arguments args) {
+static MaybeObject* Runtime_FunctionGetInferredName(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 1);
@@ -9545,7 +9763,7 @@ static int FindSharedFunctionInfosForScript(Script* script,
// For a script finds all SharedFunctionInfo's in the heap that points
// to this script. Returns JSArray of SharedFunctionInfo wrapped
// in OpaqueReferences.
-static Object* Runtime_LiveEditFindSharedFunctionInfosForScript(
+static MaybeObject* Runtime_LiveEditFindSharedFunctionInfosForScript(
Arguments args) {
ASSERT(args.length() == 1);
HandleScope scope;
@@ -9578,7 +9796,7 @@ static Object* Runtime_LiveEditFindSharedFunctionInfosForScript(
// Returns a JSArray of compilation infos. The array is ordered so that
// each function with all its descendant is always stored in a continues range
// with the function itself going first. The root function is a script function.
-static Object* Runtime_LiveEditGatherCompileInfo(Arguments args) {
+static MaybeObject* Runtime_LiveEditGatherCompileInfo(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_CHECKED(JSValue, script, args[0]);
@@ -9597,7 +9815,7 @@ static Object* Runtime_LiveEditGatherCompileInfo(Arguments args) {
// Changes the source of the script to a new_source.
// If old_script_name is provided (i.e. is a String), also creates a copy of
// the script with its original source and sends notification to debugger.
-static Object* Runtime_LiveEditReplaceScript(Arguments args) {
+static MaybeObject* Runtime_LiveEditReplaceScript(Arguments args) {
ASSERT(args.length() == 3);
HandleScope scope;
CONVERT_CHECKED(JSValue, original_script_value, args[0]);
@@ -9621,7 +9839,7 @@ static Object* Runtime_LiveEditReplaceScript(Arguments args) {
}
// Replaces code of SharedFunctionInfo with a new one.
-static Object* Runtime_LiveEditReplaceFunctionCode(Arguments args) {
+static MaybeObject* Runtime_LiveEditReplaceFunctionCode(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSArray, new_compile_info, 0);
@@ -9631,7 +9849,7 @@ static Object* Runtime_LiveEditReplaceFunctionCode(Arguments args) {
}
// Connects SharedFunctionInfo to another script.
-static Object* Runtime_LiveEditFunctionSetScript(Arguments args) {
+static MaybeObject* Runtime_LiveEditFunctionSetScript(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
Handle<Object> function_object(args[0]);
@@ -9656,7 +9874,7 @@ static Object* Runtime_LiveEditFunctionSetScript(Arguments args) {
// In a code of a parent function replaces original function as embedded object
// with a substitution one.
-static Object* Runtime_LiveEditReplaceRefToNestedFunction(Arguments args) {
+static MaybeObject* Runtime_LiveEditReplaceRefToNestedFunction(Arguments args) {
ASSERT(args.length() == 3);
HandleScope scope;
@@ -9676,7 +9894,7 @@ static Object* Runtime_LiveEditReplaceRefToNestedFunction(Arguments args) {
// array of groups of 3 numbers:
// (change_begin, change_end, change_end_new_position).
// Each group describes a change in text; groups are sorted by change_begin.
-static Object* Runtime_LiveEditPatchFunctionPositions(Arguments args) {
+static MaybeObject* Runtime_LiveEditPatchFunctionPositions(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSArray, shared_array, 0);
@@ -9690,7 +9908,7 @@ static Object* Runtime_LiveEditPatchFunctionPositions(Arguments args) {
// checks that none of them have activations on stacks (of any thread).
// Returns array of the same length with corresponding results of
// LiveEdit::FunctionPatchabilityStatus type.
-static Object* Runtime_LiveEditCheckAndDropActivations(Arguments args) {
+static MaybeObject* Runtime_LiveEditCheckAndDropActivations(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSArray, shared_array, 0);
@@ -9701,7 +9919,7 @@ static Object* Runtime_LiveEditCheckAndDropActivations(Arguments args) {
// Compares 2 strings line-by-line and returns diff in form of JSArray of
// triplets (pos1, pos1_end, pos2_end) describing list of diff chunks.
-static Object* Runtime_LiveEditCompareStringsLinewise(Arguments args) {
+static MaybeObject* Runtime_LiveEditCompareStringsLinewise(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(String, s1, 0);
@@ -9714,7 +9932,7 @@ static Object* Runtime_LiveEditCompareStringsLinewise(Arguments args) {
// A testing entry. Returns statement position which is the closest to
// source_position.
-static Object* Runtime_GetFunctionCodePositionFromSource(Arguments args) {
+static MaybeObject* Runtime_GetFunctionCodePositionFromSource(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSFunction, function, 0);
@@ -9746,7 +9964,7 @@ static Object* Runtime_GetFunctionCodePositionFromSource(Arguments args) {
// Calls specified function with or without entering the debugger.
// This is used in unit tests to run code as if debugger is entered or simply
// to have a stack with C++ frame in the middle.
-static Object* Runtime_ExecuteInDebugContext(Arguments args) {
+static MaybeObject* Runtime_ExecuteInDebugContext(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSFunction, function, 0);
@@ -9776,7 +9994,7 @@ static Object* Runtime_ExecuteInDebugContext(Arguments args) {
#ifdef ENABLE_LOGGING_AND_PROFILING
-static Object* Runtime_ProfilerResume(Arguments args) {
+static MaybeObject* Runtime_ProfilerResume(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -9787,7 +10005,7 @@ static Object* Runtime_ProfilerResume(Arguments args) {
}
-static Object* Runtime_ProfilerPause(Arguments args) {
+static MaybeObject* Runtime_ProfilerPause(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
@@ -9834,7 +10052,7 @@ static Handle<Object> Runtime_GetScriptFromScriptName(
// Get the script object from script data. NOTE: Regarding performance
// see the NOTE for GetScriptFromScriptData.
// args[0]: script data for the script to find the source for
-static Object* Runtime_GetScript(Arguments args) {
+static MaybeObject* Runtime_GetScript(Arguments args) {
HandleScope scope;
ASSERT(args.length() == 1);
@@ -9879,7 +10097,7 @@ static bool ShowFrameInStackTrace(StackFrame* raw_frame, Object* caller,
// Collect the raw data for a stack trace. Returns an array of three
// element segments each containing a receiver, function and native
// code offset.
-static Object* Runtime_CollectStackTrace(Arguments args) {
+static MaybeObject* Runtime_CollectStackTrace(Arguments args) {
ASSERT_EQ(args.length(), 2);
Handle<Object> caller = args.at<Object>(0);
CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[1]);
@@ -9929,7 +10147,7 @@ static Object* Runtime_CollectStackTrace(Arguments args) {
// Returns V8 version as a string.
-static Object* Runtime_GetV8Version(Arguments args) {
+static MaybeObject* Runtime_GetV8Version(Arguments args) {
ASSERT_EQ(args.length(), 0);
NoHandleAllocation ha;
@@ -9940,7 +10158,7 @@ static Object* Runtime_GetV8Version(Arguments args) {
}
-static Object* Runtime_Abort(Arguments args) {
+static MaybeObject* Runtime_Abort(Arguments args) {
ASSERT(args.length() == 2);
OS::PrintError("abort: %s\n", reinterpret_cast<char*>(args[0]) +
Smi::cast(args[1])->value());
@@ -9951,14 +10169,9 @@ static Object* Runtime_Abort(Arguments args) {
}
-static Object* Runtime_DeleteHandleScopeExtensions(Arguments args) {
- ASSERT(args.length() == 0);
- HandleScope::DeleteExtensions();
- return Heap::undefined_value();
-}
-
-
-static Object* CacheMiss(FixedArray* cache_obj, int index, Object* key_obj) {
+MUST_USE_RESULT static MaybeObject* CacheMiss(FixedArray* cache_obj,
+ int index,
+ Object* key_obj) {
ASSERT(index % 2 == 0); // index of the key
ASSERT(index >= JSFunctionResultCache::kEntriesIndex);
ASSERT(index < cache_obj->length());
@@ -9993,7 +10206,7 @@ static Object* CacheMiss(FixedArray* cache_obj, int index, Object* key_obj) {
}
-static Object* Runtime_GetFromCache(Arguments args) {
+static MaybeObject* Runtime_GetFromCache(Arguments args) {
// This is only called from codegen, so checks might be more lax.
CONVERT_CHECKED(FixedArray, cache, args[0]);
Object* key = args[1];
@@ -10046,7 +10259,7 @@ static Object* Runtime_GetFromCache(Arguments args) {
#ifdef DEBUG
// ListNatives is ONLY used by the fuzz-natives.js in debug mode
// Exclude the code in release mode.
-static Object* Runtime_ListNatives(Arguments args) {
+static MaybeObject* Runtime_ListNatives(Arguments args) {
ASSERT(args.length() == 0);
HandleScope scope;
Handle<JSArray> result = Factory::NewJSArray(0);
@@ -10080,7 +10293,7 @@ static Object* Runtime_ListNatives(Arguments args) {
#endif
-static Object* Runtime_Log(Arguments args) {
+static MaybeObject* Runtime_Log(Arguments args) {
ASSERT(args.length() == 2);
CONVERT_CHECKED(String, format, args[0]);
CONVERT_CHECKED(JSArray, elms, args[1]);
@@ -10090,7 +10303,7 @@ static Object* Runtime_Log(Arguments args) {
}
-static Object* Runtime_IS_VAR(Arguments args) {
+static MaybeObject* Runtime_IS_VAR(Arguments args) {
UNREACHABLE(); // implemented as macro in the parser
return NULL;
}
@@ -10115,18 +10328,26 @@ Runtime::Function kIntrinsicFunctions[] = {
};
-Object* Runtime::InitializeIntrinsicFunctionNames(Object* dictionary) {
+MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Object* dictionary) {
ASSERT(dictionary != NULL);
ASSERT(StringDictionary::cast(dictionary)->NumberOfElements() == 0);
for (int i = 0; i < kNumFunctions; ++i) {
- Object* name_symbol = Heap::LookupAsciiSymbol(kIntrinsicFunctions[i].name);
- if (name_symbol->IsFailure()) return name_symbol;
+ Object* name_symbol;
+ { MaybeObject* maybe_name_symbol =
+ Heap::LookupAsciiSymbol(kIntrinsicFunctions[i].name);
+ if (!maybe_name_symbol->ToObject(&name_symbol)) return maybe_name_symbol;
+ }
StringDictionary* string_dictionary = StringDictionary::cast(dictionary);
- dictionary = string_dictionary->Add(String::cast(name_symbol),
- Smi::FromInt(i),
- PropertyDetails(NONE, NORMAL));
- // Non-recoverable failure. Calling code must restart heap initialization.
- if (dictionary->IsFailure()) return dictionary;
+ { MaybeObject* maybe_dictionary = string_dictionary->Add(
+ String::cast(name_symbol),
+ Smi::FromInt(i),
+ PropertyDetails(NONE, NORMAL));
+ if (!maybe_dictionary->ToObject(&dictionary)) {
+ // Non-recoverable failure. Calling code must restart heap
+ // initialization.
+ return maybe_dictionary;
+ }
+ }
}
return dictionary;
}
« no previous file with comments | « src/runtime.h ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698