| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins/builtins-constructor-gen.h" | 5 #include "src/builtins/builtins-constructor-gen.h" |
| 6 | 6 |
| 7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
| 8 #include "src/builtins/builtins-constructor.h" | 8 #include "src/builtins/builtins-constructor.h" |
| 9 #include "src/builtins/builtins-utils-gen.h" | 9 #include "src/builtins/builtins-utils-gen.h" |
| 10 #include "src/builtins/builtins.h" | 10 #include "src/builtins/builtins.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 BIND(&allocate_properties); | 252 BIND(&allocate_properties); |
| 253 { | 253 { |
| 254 properties.Bind(AllocateNameDictionary(NameDictionary::kInitialCapacity)); | 254 properties.Bind(AllocateNameDictionary(NameDictionary::kInitialCapacity)); |
| 255 Goto(&instantiate_map); | 255 Goto(&instantiate_map); |
| 256 } | 256 } |
| 257 | 257 |
| 258 BIND(&instantiate_map); | 258 BIND(&instantiate_map); |
| 259 | 259 |
| 260 Node* object = AllocateJSObjectFromMap(initial_map, properties.value()); | 260 Node* object = AllocateJSObjectFromMap(initial_map, properties.value()); |
| 261 | 261 |
| 262 Node* instance_size_words = ChangeUint32ToWord(LoadObjectField( | |
| 263 initial_map, Map::kInstanceSizeOffset, MachineType::Uint8())); | |
| 264 Node* instance_size = | |
| 265 WordShl(instance_size_words, IntPtrConstant(kPointerSizeLog2)); | |
| 266 | |
| 267 // Perform in-object slack tracking if requested. | 262 // Perform in-object slack tracking if requested. |
| 268 Node* bit_field3 = LoadMapBitField3(initial_map); | 263 HandleSlackTracking(context, object, initial_map, JSObject::kHeaderSize); |
| 269 Label slack_tracking(this), finalize(this, Label::kDeferred), done(this); | |
| 270 GotoIf(IsSetWord32<Map::ConstructionCounter>(bit_field3), &slack_tracking); | |
| 271 | |
| 272 // Initialize remaining fields. | |
| 273 { | |
| 274 Comment("no slack tracking"); | |
| 275 InitializeFieldsWithRoot(object, IntPtrConstant(JSObject::kHeaderSize), | |
| 276 instance_size, Heap::kUndefinedValueRootIndex); | |
| 277 Goto(&end); | |
| 278 } | |
| 279 | |
| 280 { | |
| 281 BIND(&slack_tracking); | |
| 282 | |
| 283 // Decrease generous allocation count. | |
| 284 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); | |
| 285 Comment("update allocation count"); | |
| 286 Node* new_bit_field3 = Int32Sub( | |
| 287 bit_field3, Int32Constant(1 << Map::ConstructionCounter::kShift)); | |
| 288 StoreObjectFieldNoWriteBarrier(initial_map, Map::kBitField3Offset, | |
| 289 new_bit_field3, | |
| 290 MachineRepresentation::kWord32); | |
| 291 GotoIf(IsClearWord32<Map::ConstructionCounter>(new_bit_field3), &finalize); | |
| 292 | |
| 293 Node* unused_fields = LoadObjectField( | |
| 294 initial_map, Map::kUnusedPropertyFieldsOffset, MachineType::Uint8()); | |
| 295 Node* used_size = | |
| 296 IntPtrSub(instance_size, WordShl(ChangeUint32ToWord(unused_fields), | |
| 297 IntPtrConstant(kPointerSizeLog2))); | |
| 298 | |
| 299 Comment("initialize filler fields (no finalize)"); | |
| 300 InitializeFieldsWithRoot(object, used_size, instance_size, | |
| 301 Heap::kOnePointerFillerMapRootIndex); | |
| 302 | |
| 303 Comment("initialize undefined fields (no finalize)"); | |
| 304 InitializeFieldsWithRoot(object, IntPtrConstant(JSObject::kHeaderSize), | |
| 305 used_size, Heap::kUndefinedValueRootIndex); | |
| 306 Goto(&end); | |
| 307 } | |
| 308 | |
| 309 { | |
| 310 // Finalize the instance size. | |
| 311 BIND(&finalize); | |
| 312 | |
| 313 Node* unused_fields = LoadObjectField( | |
| 314 initial_map, Map::kUnusedPropertyFieldsOffset, MachineType::Uint8()); | |
| 315 Node* used_size = | |
| 316 IntPtrSub(instance_size, WordShl(ChangeUint32ToWord(unused_fields), | |
| 317 IntPtrConstant(kPointerSizeLog2))); | |
| 318 | |
| 319 Comment("initialize filler fields (finalize)"); | |
| 320 InitializeFieldsWithRoot(object, used_size, instance_size, | |
| 321 Heap::kOnePointerFillerMapRootIndex); | |
| 322 | |
| 323 Comment("initialize undefined fields (finalize)"); | |
| 324 InitializeFieldsWithRoot(object, IntPtrConstant(JSObject::kHeaderSize), | |
| 325 used_size, Heap::kUndefinedValueRootIndex); | |
| 326 | |
| 327 CallRuntime(Runtime::kFinalizeInstanceSize, context, initial_map); | |
| 328 Goto(&end); | |
| 329 } | |
| 330 | |
| 331 BIND(&end); | |
| 332 return object; | 264 return object; |
| 333 } | 265 } |
| 334 | 266 |
| 335 Node* ConstructorBuiltinsAssembler::EmitFastNewFunctionContext( | 267 Node* ConstructorBuiltinsAssembler::EmitFastNewFunctionContext( |
| 336 Node* function, Node* slots, Node* context, ScopeType scope_type) { | 268 Node* function, Node* slots, Node* context, ScopeType scope_type) { |
| 337 slots = ChangeUint32ToWord(slots); | 269 slots = ChangeUint32ToWord(slots); |
| 338 | 270 |
| 339 // TODO(ishell): Use CSA::OptimalParameterMode() here. | 271 // TODO(ishell): Use CSA::OptimalParameterMode() here. |
| 340 ParameterMode mode = INTPTR_PARAMETERS; | 272 ParameterMode mode = INTPTR_PARAMETERS; |
| 341 Node* min_context_slots = IntPtrConstant(Context::MIN_CONTEXT_SLOTS); | 273 Node* min_context_slots = IntPtrConstant(Context::MIN_CONTEXT_SLOTS); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 SHALLOW_OBJECT_BUILTIN(0); | 668 SHALLOW_OBJECT_BUILTIN(0); |
| 737 SHALLOW_OBJECT_BUILTIN(1); | 669 SHALLOW_OBJECT_BUILTIN(1); |
| 738 SHALLOW_OBJECT_BUILTIN(2); | 670 SHALLOW_OBJECT_BUILTIN(2); |
| 739 SHALLOW_OBJECT_BUILTIN(3); | 671 SHALLOW_OBJECT_BUILTIN(3); |
| 740 SHALLOW_OBJECT_BUILTIN(4); | 672 SHALLOW_OBJECT_BUILTIN(4); |
| 741 SHALLOW_OBJECT_BUILTIN(5); | 673 SHALLOW_OBJECT_BUILTIN(5); |
| 742 SHALLOW_OBJECT_BUILTIN(6); | 674 SHALLOW_OBJECT_BUILTIN(6); |
| 743 | 675 |
| 744 } // namespace internal | 676 } // namespace internal |
| 745 } // namespace v8 | 677 } // namespace v8 |
| OLD | NEW |