OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 return *result; | 1035 return *result; |
1036 } | 1036 } |
1037 | 1037 |
1038 | 1038 |
1039 RUNTIME_FUNCTION(Runtime_NewObject) { | 1039 RUNTIME_FUNCTION(Runtime_NewObject) { |
1040 HandleScope scope(isolate); | 1040 HandleScope scope(isolate); |
1041 DCHECK(args.length() == 2); | 1041 DCHECK(args.length() == 2); |
1042 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); | 1042 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); |
1043 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, 1); | 1043 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, 1); |
1044 | 1044 |
1045 // TODO(verwaest): Make sure |constructor| is guaranteed to be a constructor. | 1045 DCHECK(constructor->IsConstructor()); |
1046 if (!constructor->IsConstructor()) { | |
1047 THROW_NEW_ERROR_RETURN_FAILURE( | |
1048 isolate, NewTypeError(MessageTemplate::kNotConstructor, constructor)); | |
1049 } | |
1050 | 1046 |
1051 // If called through new, new.target can be: | 1047 // If called through new, new.target can be: |
1052 // - a subclass of constructor, | 1048 // - a subclass of constructor, |
1053 // - a proxy wrapper around constructor, or | 1049 // - a proxy wrapper around constructor, or |
1054 // - the constructor itself. | 1050 // - the constructor itself. |
1055 // If called through Reflect.construct, it's guaranteed to be a constructor by | 1051 // If called through Reflect.construct, it's guaranteed to be a constructor by |
1056 // REFLECT_CONSTRUCT_PREPARE. | 1052 // REFLECT_CONSTRUCT_PREPARE. |
1057 DCHECK(new_target->IsConstructor()); | 1053 DCHECK(new_target->IsConstructor()); |
1058 | 1054 |
1059 return Runtime_NewObjectHelper(isolate, constructor, new_target, | 1055 return Runtime_NewObjectHelper(isolate, constructor, new_target, |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 | 1581 |
1586 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { | 1582 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { |
1587 HandleScope scope(isolate); | 1583 HandleScope scope(isolate); |
1588 DCHECK(args.length() == 2); | 1584 DCHECK(args.length() == 2); |
1589 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); | 1585 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); |
1590 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); | 1586 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); |
1591 return JSReceiver::DefineProperties(isolate, o, properties); | 1587 return JSReceiver::DefineProperties(isolate, o, properties); |
1592 } | 1588 } |
1593 } // namespace internal | 1589 } // namespace internal |
1594 } // namespace v8 | 1590 } // namespace v8 |
OLD | NEW |