Chromium Code Reviews| Index: src/runtime.cc |
| diff --git a/src/runtime.cc b/src/runtime.cc |
| index 48022b049c0790f18292984843e39aaa3872e9db..0fbd9c2cc082d2b5de218797909b4aac75257a21 100644 |
| --- a/src/runtime.cc |
| +++ b/src/runtime.cc |
| @@ -673,7 +673,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateArrayLiteralShallow) { |
| RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { |
| ASSERT(args.length() == 2); |
| - Object* handler = args[0]; |
| + CONVERT_ARG_CHECKED(JSReceiver, handler, 0); |
| Object* prototype = args[1]; |
| Object* used_prototype = |
| prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); |
| @@ -683,9 +683,10 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { |
| RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSFunctionProxy) { |
| ASSERT(args.length() == 4); |
| - Object* handler = args[0]; |
| + CONVERT_ARG_CHECKED(JSReceiver, handler, 0); |
| Object* call_trap = args[1]; |
| - Object* construct_trap = args[2]; |
| + RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); |
| + CONVERT_ARG_CHECKED(JSFunction, construct_trap, 2); |
| Object* prototype = args[3]; |
| Object* used_prototype = |
| prototype->IsJSReceiver() ? prototype : isolate->heap()->null_value(); |
| @@ -2066,8 +2067,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { |
| ASSERT(args.length() == 1); |
| CONVERT_ARG_CHECKED(JSFunction, f, 0); |
| - Object* obj = f->RemovePrototype(); |
| - if (obj->IsFailure()) return obj; |
| + f->RemovePrototype(); |
|
Erik Corry
2012/09/07 09:22:33
I wonder why RemovePrototype does not return void?
|
| return isolate->heap()->undefined_value(); |
| } |
| @@ -2307,19 +2307,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringCharCodeAt) { |
| ASSERT(args.length() == 2); |
| CONVERT_ARG_CHECKED(String, subject, 0); |
| - Object* index = args[1]; |
| - RUNTIME_ASSERT(index->IsNumber()); |
| - |
| - uint32_t i = 0; |
| - if (index->IsSmi()) { |
| - int value = Smi::cast(index)->value(); |
| - if (value < 0) return isolate->heap()->nan_value(); |
| - i = value; |
| - } else { |
| - ASSERT(index->IsHeapNumber()); |
| - double value = HeapNumber::cast(index)->value(); |
| - i = static_cast<uint32_t>(DoubleToInteger(value)); |
| - } |
| + CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); |
| // 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 |
| @@ -3289,12 +3277,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceRegExpWithString) { |
| } |
| -Handle<String> Runtime::StringReplaceOneCharWithString(Isolate* isolate, |
| - Handle<String> subject, |
| - Handle<String> search, |
| - Handle<String> replace, |
| - bool* found, |
| - int recursion_limit) { |
| +Handle<String> StringReplaceOneCharWithString(Isolate* isolate, |
| + Handle<String> subject, |
| + Handle<String> search, |
| + Handle<String> replace, |
| + bool* found, |
| + int recursion_limit) { |
| if (recursion_limit == 0) return Handle<String>::null(); |
| if (subject->IsConsString()) { |
| ConsString* cons = ConsString::cast(*subject); |
| @@ -3322,7 +3310,7 @@ Handle<String> Runtime::StringReplaceOneCharWithString(Isolate* isolate, |
| return subject; |
| } else { |
| - int index = StringMatch(isolate, subject, search, 0); |
| + int index = Runtime::StringMatch(isolate, subject, search, 0); |
| if (index == -1) return subject; |
| *found = true; |
| Handle<String> first = isolate->factory()->NewSubString(subject, 0, index); |
| @@ -3345,20 +3333,19 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceOneCharWithString) { |
| // retry with a flattened subject string. |
| const int kRecursionLimit = 0x1000; |
| bool found = false; |
| - Handle<String> result = |
| - Runtime::StringReplaceOneCharWithString(isolate, |
| - subject, |
| - search, |
| - replace, |
| - &found, |
| - kRecursionLimit); |
| + Handle<String> result = StringReplaceOneCharWithString(isolate, |
| + subject, |
| + search, |
| + replace, |
| + &found, |
| + kRecursionLimit); |
| if (!result.is_null()) return *result; |
| - return *Runtime::StringReplaceOneCharWithString(isolate, |
| - FlattenGetString(subject), |
| - search, |
| - replace, |
| - &found, |
| - kRecursionLimit); |
| + return *StringReplaceOneCharWithString(isolate, |
| + FlattenGetString(subject), |
| + search, |
| + replace, |
| + &found, |
| + kRecursionLimit); |
| } |
| @@ -8864,6 +8851,15 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowReferenceError) { |
| } |
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_ThrowNotDateError) { |
| + HandleScope scope(isolate); |
| + ASSERT(args.length() == 0); |
| + return isolate->Throw(*isolate->factory()->NewTypeError( |
| + "not_date_object", HandleVector<Object>(NULL, 0))); |
| +} |
| + |
| + |
| + |
| RUNTIME_FUNCTION(MaybeObject*, Runtime_StackGuard) { |
| ASSERT(args.length() == 0); |
| @@ -12260,7 +12256,7 @@ RUNTIME_FUNCTION(MaybeObject*, |
| HandleScope scope(isolate); |
| CONVERT_ARG_CHECKED(JSValue, script_value, 0); |
| - |
| + RUNTIME_ASSERT(script_value->value()->IsScript()); |
| Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); |
| const int kBufferSize = 32; |
| @@ -12306,6 +12302,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) { |
| HandleScope scope(isolate); |
| CONVERT_ARG_CHECKED(JSValue, script, 0); |
| CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
| + |
| + RUNTIME_ASSERT(script->value()->IsScript()); |
| Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
| JSArray* result = LiveEdit::GatherCompileInfo(script_handle, source); |