Chromium Code Reviews| Index: src/runtime/runtime-scopes.cc |
| diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc |
| index 3cca35b14aef2153a95740fb62ba029c9c013789..84e0937c09ed5c70a860d1d78d1bee89609fdcc6 100644 |
| --- a/src/runtime/runtime-scopes.cc |
| +++ b/src/runtime/runtime-scopes.cc |
| @@ -705,31 +705,14 @@ RUNTIME_FUNCTION(Runtime_NewFunctionContext) { |
| RUNTIME_FUNCTION(Runtime_PushWithContext) { |
| HandleScope scope(isolate); |
| - DCHECK(args.length() == 2); |
| + DCHECK_EQ(2, args.length()); |
| + CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
| + CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); |
| Handle<JSReceiver> extension_object; |
| - if (args[0]->IsJSReceiver()) { |
| - extension_object = args.at<JSReceiver>(0); |
| - } else { |
| - // Try to convert the object to a proper JavaScript object. |
| - MaybeHandle<JSReceiver> maybe_object = |
| - Object::ToObject(isolate, args.at<Object>(0)); |
| - if (!maybe_object.ToHandle(&extension_object)) { |
| - Handle<Object> handle = args.at<Object>(0); |
| - THROW_NEW_ERROR_RETURN_FAILURE( |
| - isolate, NewTypeError(MessageTemplate::kWithExpression, handle)); |
|
Yang
2015/11/26 12:46:04
Please also remove this message template from mess
Benedikt Meurer
2015/11/26 12:47:50
Done.
|
| - } |
| - } |
| - |
| - Handle<JSFunction> function; |
| - if (args[1]->IsSmi()) { |
| - // A smi sentinel indicates a context nested inside global code rather |
| - // than some function. There is a canonical empty function that can be |
| - // gotten from the native context. |
| - function = handle(isolate->native_context()->closure()); |
| - } else { |
| - function = args.at<JSFunction>(1); |
| + if (!Object::ToObject(isolate, value).ToHandle(&extension_object)) { |
| + THROW_NEW_ERROR_RETURN_FAILURE( |
| + isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); |
| } |
| - |
| Handle<Context> current(isolate->context()); |
| Handle<Context> context = |
| isolate->factory()->NewWithContext(function, current, extension_object); |
| @@ -740,18 +723,10 @@ RUNTIME_FUNCTION(Runtime_PushWithContext) { |
| RUNTIME_FUNCTION(Runtime_PushCatchContext) { |
| HandleScope scope(isolate); |
| - DCHECK(args.length() == 3); |
| + DCHECK_EQ(3, args.length()); |
| CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
| CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); |
| - Handle<JSFunction> function; |
| - if (args[2]->IsSmi()) { |
| - // A smi sentinel indicates a context nested inside global code rather |
| - // than some function. There is a canonical empty function that can be |
| - // gotten from the native context. |
| - function = handle(isolate->native_context()->closure()); |
| - } else { |
| - function = args.at<JSFunction>(2); |
| - } |
| + CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2); |
| Handle<Context> current(isolate->context()); |
| Handle<Context> context = isolate->factory()->NewCatchContext( |
| function, current, name, thrown_object); |
| @@ -762,17 +737,9 @@ RUNTIME_FUNCTION(Runtime_PushCatchContext) { |
| RUNTIME_FUNCTION(Runtime_PushBlockContext) { |
| HandleScope scope(isolate); |
| - DCHECK(args.length() == 2); |
| + DCHECK_EQ(2, args.length()); |
| CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); |
| - Handle<JSFunction> function; |
| - if (args[1]->IsSmi()) { |
| - // A smi sentinel indicates a context nested inside global code rather |
| - // than some function. There is a canonical empty function that can be |
| - // gotten from the native context. |
| - function = handle(isolate->native_context()->closure()); |
| - } else { |
| - function = args.at<JSFunction>(1); |
| - } |
| + CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); |
| Handle<Context> current(isolate->context()); |
| Handle<Context> context = |
| isolate->factory()->NewBlockContext(function, current, scope_info); |