Chromium Code Reviews| Index: src/runtime/runtime-classes.cc |
| diff --git a/src/runtime/runtime-classes.cc b/src/runtime/runtime-classes.cc |
| index ca309f5fecd5a89e66e2287d116741620d3e97b2..1420834ce8cdbfd89ff332460daef0a8b98c8963 100644 |
| --- a/src/runtime/runtime-classes.cc |
| +++ b/src/runtime/runtime-classes.cc |
| @@ -26,7 +26,6 @@ RUNTIME_FUNCTION(Runtime_ThrowNonMethodError) { |
| isolate, NewReferenceError(MessageTemplate::kNonMethod)); |
| } |
| - |
| RUNTIME_FUNCTION(Runtime_ThrowUnsupportedSuperError) { |
| HandleScope scope(isolate); |
| DCHECK(args.length() == 0); |
| @@ -59,6 +58,26 @@ RUNTIME_FUNCTION(Runtime_ThrowStaticPrototypeError) { |
| isolate, NewTypeError(MessageTemplate::kStaticPrototype)); |
| } |
| +namespace { |
|
Benedikt Meurer
2016/12/08 18:42:24
Nit: empty line after { and before } below.
|
| +Object* ThrowNotSuperConstructor(Isolate* isolate, |
| + Handle<JSFunction> constructor, |
| + Handle<JSFunction> function) { |
| + Handle<Object> super_name(constructor->shared()->name(), isolate); |
| + Handle<Object> function_name(function->shared()->name(), isolate); |
| + THROW_NEW_ERROR_RETURN_FAILURE( |
| + isolate, NewTypeError(MessageTemplate::kNotSuperConstructor, super_name, |
| + function_name)); |
| +} |
| +} // anonymous namespace |
| + |
| +RUNTIME_FUNCTION(Runtime_ThrowNotSuperConstructor) { |
| + HandleScope scope(isolate); |
| + DCHECK(args.length() == 2); |
| + CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); |
| + CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 1); |
| + return ThrowNotSuperConstructor(isolate, constructor, function); |
| +} |
| + |
| RUNTIME_FUNCTION(Runtime_HomeObjectSymbol) { |
| DCHECK(args.length() == 0); |
| return isolate->heap()->home_object_symbol(); |
| @@ -421,8 +440,14 @@ RUNTIME_FUNCTION(Runtime_StoreKeyedToSuper_Sloppy) { |
| RUNTIME_FUNCTION(Runtime_GetSuperConstructor) { |
| SealHandleScope shs(isolate); |
| DCHECK_EQ(1, args.length()); |
| - CONVERT_ARG_CHECKED(JSFunction, active_function, 0); |
| - return active_function->map()->prototype(); |
| + CONVERT_ARG_HANDLE_CHECKED(JSFunction, active_function, 0); |
| + Object* prototype = active_function->map()->prototype(); |
| + if (!prototype->IsConstructor()) { |
| + return ThrowNotSuperConstructor( |
| + isolate, Handle<JSFunction>::cast(handle(prototype, isolate)), |
| + active_function); |
| + } |
| + return prototype; |
| } |
| RUNTIME_FUNCTION(Runtime_NewWithSpread) { |