| 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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 788 } | 788 } | 
| 789 | 789 | 
| 790 | 790 | 
| 791 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { | 791 RUNTIME_FUNCTION(Runtime_AllocateHeapNumber) { | 
| 792   HandleScope scope(isolate); | 792   HandleScope scope(isolate); | 
| 793   DCHECK(args.length() == 0); | 793   DCHECK(args.length() == 0); | 
| 794   return *isolate->factory()->NewHeapNumber(0); | 794   return *isolate->factory()->NewHeapNumber(0); | 
| 795 } | 795 } | 
| 796 | 796 | 
| 797 | 797 | 
| 798 static Object* Runtime_NewObjectHelper(Isolate* isolate, |  | 
| 799                                        Handle<JSFunction> constructor, |  | 
| 800                                        Handle<JSReceiver> new_target, |  | 
| 801                                        Handle<AllocationSite> site) { |  | 
| 802   DCHECK(constructor->IsConstructor()); |  | 
| 803 |  | 
| 804   // If called through new, new.target can be: |  | 
| 805   // - a subclass of constructor, |  | 
| 806   // - a proxy wrapper around constructor, or |  | 
| 807   // - the constructor itself. |  | 
| 808   // If called through Reflect.construct, it's guaranteed to be a constructor by |  | 
| 809   // REFLECT_CONSTRUCT_PREPARE. |  | 
| 810   DCHECK(new_target->IsConstructor()); |  | 
| 811 |  | 
| 812   DCHECK(!constructor->has_initial_map() || |  | 
| 813          constructor->initial_map()->instance_type() != JS_FUNCTION_TYPE); |  | 
| 814 |  | 
| 815   Handle<Map> initial_map; |  | 
| 816   ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |  | 
| 817       isolate, initial_map, |  | 
| 818       JSFunction::GetDerivedMap(isolate, constructor, new_target)); |  | 
| 819 |  | 
| 820   Handle<JSObject> result = |  | 
| 821       isolate->factory()->NewJSObjectFromMap(initial_map, NOT_TENURED, site); |  | 
| 822 |  | 
| 823   isolate->counters()->constructed_objects()->Increment(); |  | 
| 824   isolate->counters()->constructed_objects_runtime()->Increment(); |  | 
| 825 |  | 
| 826   return *result; |  | 
| 827 } |  | 
| 828 |  | 
| 829 |  | 
| 830 RUNTIME_FUNCTION(Runtime_NewObject) { | 798 RUNTIME_FUNCTION(Runtime_NewObject) { | 
| 831   HandleScope scope(isolate); | 799   HandleScope scope(isolate); | 
| 832   DCHECK(args.length() == 2); | 800   DCHECK_EQ(2, args.length()); | 
| 833   CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); | 801   CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); | 
| 834   CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, 1); | 802   CONVERT_ARG_HANDLE_CHECKED(JSReceiver, new_target, 1); | 
| 835 | 803   Handle<JSObject> result; | 
| 836   return Runtime_NewObjectHelper(isolate, constructor, new_target, | 804   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 
| 837                                  Handle<AllocationSite>::null()); | 805                                      JSObject::New(target, new_target)); | 
|  | 806   return *result; | 
| 838 } | 807 } | 
| 839 | 808 | 
| 840 | 809 | 
| 841 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { | 810 RUNTIME_FUNCTION(Runtime_FinalizeInstanceSize) { | 
| 842   HandleScope scope(isolate); | 811   HandleScope scope(isolate); | 
| 843   DCHECK(args.length() == 1); | 812   DCHECK(args.length() == 1); | 
| 844 | 813 | 
| 845   CONVERT_ARG_HANDLE_CHECKED(Map, initial_map, 0); | 814   CONVERT_ARG_HANDLE_CHECKED(Map, initial_map, 0); | 
| 846   initial_map->CompleteInobjectSlackTracking(); | 815   initial_map->CompleteInobjectSlackTracking(); | 
| 847 | 816 | 
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1349   DCHECK(args.length() == 2); | 1318   DCHECK(args.length() == 2); | 
| 1350   CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); | 1319   CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); | 
| 1351   CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); | 1320   CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); | 
| 1352   ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1321   ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 
| 1353       isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); | 1322       isolate, o, JSReceiver::DefineProperties(isolate, o, properties)); | 
| 1354   return *o; | 1323   return *o; | 
| 1355 } | 1324 } | 
| 1356 | 1325 | 
| 1357 }  // namespace internal | 1326 }  // namespace internal | 
| 1358 }  // namespace v8 | 1327 }  // namespace v8 | 
| OLD | NEW | 
|---|