OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 13190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13201 if (function->has_initial_map() && | 13201 if (function->has_initial_map() && |
13202 function->initial_map()->GetConstructor() == *constructor) { | 13202 function->initial_map()->GetConstructor() == *constructor) { |
13203 return handle(function->initial_map(), isolate); | 13203 return handle(function->initial_map(), isolate); |
13204 } | 13204 } |
13205 | 13205 |
13206 // Create a new map with the size and number of in-object properties | 13206 // Create a new map with the size and number of in-object properties |
13207 // suggested by |function|. | 13207 // suggested by |function|. |
13208 | 13208 |
13209 // Link initial map and constructor function if the new.target is actually a | 13209 // Link initial map and constructor function if the new.target is actually a |
13210 // subclass constructor. | 13210 // subclass constructor. |
13211 if (IsSubclassConstructor(function->shared()->kind())) { | 13211 if (IsDerivedConstructor(function->shared()->kind())) { |
13212 Handle<Object> prototype(function->instance_prototype(), isolate); | 13212 Handle<Object> prototype(function->instance_prototype(), isolate); |
13213 InstanceType instance_type = constructor_initial_map->instance_type(); | 13213 InstanceType instance_type = constructor_initial_map->instance_type(); |
13214 DCHECK(CanSubclassHaveInobjectProperties(instance_type)); | 13214 DCHECK(CanSubclassHaveInobjectProperties(instance_type)); |
13215 int internal_fields = | 13215 int internal_fields = |
13216 JSObject::GetInternalFieldCount(*constructor_initial_map); | 13216 JSObject::GetInternalFieldCount(*constructor_initial_map); |
13217 int pre_allocated = constructor_initial_map->GetInObjectProperties() - | 13217 int pre_allocated = constructor_initial_map->GetInObjectProperties() - |
13218 constructor_initial_map->unused_property_fields(); | 13218 constructor_initial_map->unused_property_fields(); |
13219 int instance_size; | 13219 int instance_size; |
13220 int in_object_properties; | 13220 int in_object_properties; |
13221 function->CalculateInstanceSizeForDerivedClass( | 13221 function->CalculateInstanceSizeForDerivedClass( |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13885 int* instance_size, int* in_object_properties) { | 13885 int* instance_size, int* in_object_properties) { |
13886 Isolate* isolate = GetIsolate(); | 13886 Isolate* isolate = GetIsolate(); |
13887 int expected_nof_properties = 0; | 13887 int expected_nof_properties = 0; |
13888 for (PrototypeIterator iter(isolate, this, kStartAtReceiver); !iter.IsAtEnd(); | 13888 for (PrototypeIterator iter(isolate, this, kStartAtReceiver); !iter.IsAtEnd(); |
13889 iter.Advance()) { | 13889 iter.Advance()) { |
13890 JSReceiver* current = iter.GetCurrent<JSReceiver>(); | 13890 JSReceiver* current = iter.GetCurrent<JSReceiver>(); |
13891 if (!current->IsJSFunction()) break; | 13891 if (!current->IsJSFunction()) break; |
13892 JSFunction* func = JSFunction::cast(current); | 13892 JSFunction* func = JSFunction::cast(current); |
13893 SharedFunctionInfo* shared = func->shared(); | 13893 SharedFunctionInfo* shared = func->shared(); |
13894 expected_nof_properties += shared->expected_nof_properties(); | 13894 expected_nof_properties += shared->expected_nof_properties(); |
13895 if (!IsSubclassConstructor(shared->kind())) { | 13895 if (!IsDerivedConstructor(shared->kind())) { |
13896 break; | 13896 break; |
13897 } | 13897 } |
13898 } | 13898 } |
13899 CalculateInstanceSizeHelper(instance_type, requested_internal_fields, | 13899 CalculateInstanceSizeHelper(instance_type, requested_internal_fields, |
13900 expected_nof_properties, instance_size, | 13900 expected_nof_properties, instance_size, |
13901 in_object_properties); | 13901 in_object_properties); |
13902 } | 13902 } |
13903 | 13903 |
13904 | 13904 |
13905 // Output the source code without any allocation in the heap. | 13905 // Output the source code without any allocation in the heap. |
(...skipping 6435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20341 // depend on this. | 20341 // depend on this. |
20342 return DICTIONARY_ELEMENTS; | 20342 return DICTIONARY_ELEMENTS; |
20343 } | 20343 } |
20344 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20344 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20345 return kind; | 20345 return kind; |
20346 } | 20346 } |
20347 } | 20347 } |
20348 | 20348 |
20349 } // namespace internal | 20349 } // namespace internal |
20350 } // namespace v8 | 20350 } // namespace v8 |
OLD | NEW |