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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 | 977 |
978 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { | 978 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { |
979 HandleScope scope(isolate); | 979 HandleScope scope(isolate); |
980 DCHECK(args.length() == 0); | 980 DCHECK(args.length() == 0); |
981 return *isolate->factory()->NewHeapNumber(0); | 981 return *isolate->factory()->NewHeapNumber(0); |
982 } | 982 } |
983 | 983 |
984 | 984 |
985 static Object* Runtime_NewObjectHelper(Isolate* isolate, | 985 static Object* Runtime_NewObjectHelper(Isolate* isolate, |
986 Handle<Object> constructor, | 986 Handle<Object> constructor, |
987 Handle<Object> original_constructor, | 987 Handle<Object> new_target, |
988 Handle<AllocationSite> site) { | 988 Handle<AllocationSite> site) { |
989 // If the constructor isn't a proper function we throw a type error. | 989 // If the constructor isn't a proper function we throw a type error. |
990 if (!constructor->IsJSFunction()) { | 990 if (!constructor->IsJSFunction()) { |
991 THROW_NEW_ERROR_RETURN_FAILURE( | 991 THROW_NEW_ERROR_RETURN_FAILURE( |
992 isolate, NewTypeError(MessageTemplate::kNotConstructor, constructor)); | 992 isolate, NewTypeError(MessageTemplate::kNotConstructor, constructor)); |
993 } | 993 } |
994 | 994 |
995 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); | 995 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); |
996 | 996 |
997 CHECK(original_constructor->IsJSFunction()); | 997 CHECK(new_target->IsJSFunction()); |
998 Handle<JSFunction> original_function = | 998 Handle<JSFunction> original_function = Handle<JSFunction>::cast(new_target); |
999 Handle<JSFunction>::cast(original_constructor); | |
1000 | 999 |
1001 | 1000 |
1002 // Check that function is a constructor. | 1001 // Check that function is a constructor. |
1003 if (!function->IsConstructor()) { | 1002 if (!function->IsConstructor()) { |
1004 THROW_NEW_ERROR_RETURN_FAILURE( | 1003 THROW_NEW_ERROR_RETURN_FAILURE( |
1005 isolate, NewTypeError(MessageTemplate::kNotConstructor, constructor)); | 1004 isolate, NewTypeError(MessageTemplate::kNotConstructor, constructor)); |
1006 } | 1005 } |
1007 | 1006 |
1008 Debug* debug = isolate->debug(); | 1007 Debug* debug = isolate->debug(); |
1009 // Handle stepping into constructors if step into is active. | 1008 // Handle stepping into constructors if step into is active. |
(...skipping 21 matching lines...) Expand all Loading... |
1031 isolate->counters()->constructed_objects_runtime()->Increment(); | 1030 isolate->counters()->constructed_objects_runtime()->Increment(); |
1032 | 1031 |
1033 return *result; | 1032 return *result; |
1034 } | 1033 } |
1035 | 1034 |
1036 | 1035 |
1037 RUNTIME_FUNCTION(Runtime_NewObject) { | 1036 RUNTIME_FUNCTION(Runtime_NewObject) { |
1038 HandleScope scope(isolate); | 1037 HandleScope scope(isolate); |
1039 DCHECK(args.length() == 2); | 1038 DCHECK(args.length() == 2); |
1040 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); | 1039 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); |
1041 CONVERT_ARG_HANDLE_CHECKED(Object, original_constructor, 1); | 1040 CONVERT_ARG_HANDLE_CHECKED(Object, new_target, 1); |
1042 return Runtime_NewObjectHelper(isolate, constructor, original_constructor, | 1041 return Runtime_NewObjectHelper(isolate, constructor, new_target, |
1043 Handle<AllocationSite>::null()); | 1042 Handle<AllocationSite>::null()); |
1044 } | 1043 } |
1045 | 1044 |
1046 | 1045 |
1047 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { | 1046 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { |
1048 HandleScope scope(isolate); | 1047 HandleScope scope(isolate); |
1049 DCHECK(args.length() == 1); | 1048 DCHECK(args.length() == 1); |
1050 | 1049 |
1051 CONVERT_ARG_HANDLE_CHECKED(Map, initial_map, 0); | 1050 CONVERT_ARG_HANDLE_CHECKED(Map, initial_map, 0); |
1052 initial_map->CompleteInobjectSlackTracking(); | 1051 initial_map->CompleteInobjectSlackTracking(); |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 | 1567 |
1569 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { | 1568 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { |
1570 HandleScope scope(isolate); | 1569 HandleScope scope(isolate); |
1571 DCHECK(args.length() == 2); | 1570 DCHECK(args.length() == 2); |
1572 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); | 1571 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); |
1573 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); | 1572 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); |
1574 return JSReceiver::DefineProperties(isolate, o, properties); | 1573 return JSReceiver::DefineProperties(isolate, o, properties); |
1575 } | 1574 } |
1576 } // namespace internal | 1575 } // namespace internal |
1577 } // namespace v8 | 1576 } // namespace v8 |
OLD | NEW |