| Index: src/runtime/runtime-classes.cc
|
| diff --git a/src/runtime/runtime-classes.cc b/src/runtime/runtime-classes.cc
|
| index ca309f5fecd5a89e66e2287d116741620d3e97b2..de8f2bd387b0871a6d2e0b96be872e2babb0ddae 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,36 @@ RUNTIME_FUNCTION(Runtime_ThrowStaticPrototypeError) {
|
| isolate, NewTypeError(MessageTemplate::kStaticPrototype));
|
| }
|
|
|
| +namespace {
|
| +
|
| +Object* ThrowNotSuperConstructor(Isolate* isolate, Handle<Object> constructor,
|
| + Handle<JSFunction> function) {
|
| + Handle<Object> super_name;
|
| + if (constructor->IsJSFunction()) {
|
| + super_name = handle(Handle<JSFunction>::cast(constructor)->shared()->name(),
|
| + isolate);
|
| + } else if (constructor->IsOddball()) {
|
| + DCHECK(constructor->IsNull());
|
| + super_name = isolate->factory()->null_string();
|
| + } else {
|
| + super_name = Object::NoSideEffectsToString(isolate, constructor);
|
| + }
|
| + Handle<Object> function_name(function->shared()->name(), isolate);
|
| + THROW_NEW_ERROR_RETURN_FAILURE(
|
| + isolate, NewTypeError(MessageTemplate::kNotSuperConstructor, super_name,
|
| + function_name));
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +RUNTIME_FUNCTION(Runtime_ThrowNotSuperConstructor) {
|
| + HandleScope scope(isolate);
|
| + DCHECK(args.length() == 2);
|
| + CONVERT_ARG_HANDLE_CHECKED(Object, 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 +450,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) {
|
|
|