Chromium Code Reviews| Index: src/runtime.cc |
| diff --git a/src/runtime.cc b/src/runtime.cc |
| index 0c15f60f30677bc02c172b4f6929e5ac559273cd..df0cb9d8b316f2d6739a1886d8b0e21251ebeb01 100644 |
| --- a/src/runtime.cc |
| +++ b/src/runtime.cc |
| @@ -1469,7 +1469,8 @@ static MaybeObject* Runtime_InitializeConstContextSlot(Arguments args) { |
| // The holder is an arguments object. |
| ASSERT((attributes & READ_ONLY) == 0); |
| Handle<JSObject> arguments(Handle<JSObject>::cast(holder)); |
| - SetElement(arguments, index, value); |
| + Handle<Object> result = SetElement(arguments, index, value); |
| + if (result.is_null()) return Failure::Exception(); |
|
antonm
2011/03/02 20:28:47
you may use RETURN_IF_EMPTY_HANDLE
|
| } |
| return *value; |
| } |
| @@ -8659,8 +8660,12 @@ static MaybeObject* Runtime_SwapElements(Arguments args) { |
| Handle<Object> tmp1 = GetElement(jsobject, index1); |
| Handle<Object> tmp2 = GetElement(jsobject, index2); |
| - SetElement(jsobject, index1, tmp2); |
| - SetElement(jsobject, index2, tmp1); |
| + if (SetElement(jsobject, index1, tmp2).is_null()) { |
|
antonm
2011/03/02 20:28:47
Ditto
|
| + return Failure::Exception(); |
| + } |
| + if (SetElement(jsobject, index2, tmp1).is_null()) { |
| + return Failure::Exception(); |
| + } |
| return Heap::undefined_value(); |
| } |
| @@ -11266,7 +11271,8 @@ static MaybeObject* Runtime_CollectStackTrace(Arguments args) { |
| limit = Max(limit, 0); // Ensure that limit is not negative. |
| int initial_size = Min(limit, 10); |
| - Handle<JSArray> result = Factory::NewJSArray(initial_size * 4); |
| + Handle<FixedArray> elements = |
| + Factory::NewFixedArrayWithHoles(initial_size * 4); |
| StackFrameIterator iter; |
| // If the caller parameter is a function we skip frames until we're |
| @@ -11282,27 +11288,30 @@ static MaybeObject* Runtime_CollectStackTrace(Arguments args) { |
| List<FrameSummary> frames(3); // Max 2 levels of inlining. |
| frame->Summarize(&frames); |
| for (int i = frames.length() - 1; i >= 0; i--) { |
| + if (cursor + 4 > elements->length()) { |
| + int new_capacity = JSObject::NewElementsCapacity(elements->length()); |
| + Handle<FixedArray> new_elements = |
| + Factory::NewFixedArrayWithHoles(new_capacity); |
| + for (int i = 0; i < cursor; i++) { |
| + new_elements->set(i, elements->get(i)); |
| + } |
| + elements = new_elements; |
| + } |
| + ASSERT(cursor + 4 <= elements->length()); |
| + |
| Handle<Object> recv = frames[i].receiver(); |
| Handle<JSFunction> fun = frames[i].function(); |
| Handle<Code> code = frames[i].code(); |
| Handle<Smi> offset(Smi::FromInt(frames[i].offset())); |
| - FixedArray* elements = FixedArray::cast(result->elements()); |
| - if (cursor + 3 < elements->length()) { |
| - elements->set(cursor++, *recv); |
| - elements->set(cursor++, *fun); |
| - elements->set(cursor++, *code); |
| - elements->set(cursor++, *offset); |
| - } else { |
| - SetElement(result, cursor++, recv); |
| - SetElement(result, cursor++, fun); |
| - SetElement(result, cursor++, code); |
| - SetElement(result, cursor++, offset); |
| - } |
| + elements->set(cursor++, *recv); |
| + elements->set(cursor++, *fun); |
| + elements->set(cursor++, *code); |
| + elements->set(cursor++, *offset); |
| } |
| } |
| iter.Advance(); |
| } |
| - |
| + Handle<JSArray> result = Factory::NewJSArrayWithElements(elements); |
| result->set_length(Smi::FromInt(cursor)); |
| return *result; |
| } |
| @@ -11467,7 +11476,13 @@ static MaybeObject* Runtime_MessageGetScript(Arguments args) { |
| static MaybeObject* Runtime_ListNatives(Arguments args) { |
| ASSERT(args.length() == 0); |
| HandleScope scope; |
| - Handle<JSArray> result = Factory::NewJSArray(0); |
| +#define COUNT_ENTRY(Name, argc, ressize) + 1 |
| + int entry_count = 0 |
| + RUNTIME_FUNCTION_LIST(COUNT_ENTRY) |
| + INLINE_FUNCTION_LIST(COUNT_ENTRY) |
| + INLINE_RUNTIME_FUNCTION_LIST(COUNT_ENTRY); |
| +#undef COUNT_ENTRY |
| + Handle<FixedArray> elements = Factory::NewFixedArray(entry_count); |
| int index = 0; |
| bool inline_runtime_functions = false; |
| #define ADD_ENTRY(Name, argc, ressize) \ |
| @@ -11482,10 +11497,11 @@ static MaybeObject* Runtime_ListNatives(Arguments args) { |
| name = Factory::NewStringFromAscii( \ |
| Vector<const char>(#Name, StrLength(#Name))); \ |
| } \ |
| - Handle<JSArray> pair = Factory::NewJSArray(0); \ |
| - SetElement(pair, 0, name); \ |
| - SetElement(pair, 1, Handle<Smi>(Smi::FromInt(argc))); \ |
| - SetElement(result, index++, pair); \ |
| + Handle<FixedArray> pair_elements = Factory::NewFixedArray(2); \ |
| + pair_elements->set(0, *name); \ |
| + pair_elements->set(1, Smi::FromInt(argc)); \ |
| + Handle<JSArray> pair = Factory::NewJSArrayWithElements(pair_elements); \ |
| + elements->set(index++, *pair); \ |
| } |
| inline_runtime_functions = false; |
| RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
| @@ -11493,6 +11509,8 @@ static MaybeObject* Runtime_ListNatives(Arguments args) { |
| INLINE_FUNCTION_LIST(ADD_ENTRY) |
| INLINE_RUNTIME_FUNCTION_LIST(ADD_ENTRY) |
| #undef ADD_ENTRY |
| + ASSERT_EQ(index, entry_count); |
| + Handle<JSArray> result = Factory::NewJSArrayWithElements(elements); |
| return *result; |
| } |
| #endif |