Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: src/builtins/builtins-constructor-gen.cc

Issue 2760953002: [builtins] Move more files into v8_builtins_generators source set (Closed)
Patch Set: rebased Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/builtins-constructor-gen.h ('k') | src/builtins/builtins-forin.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
6
5 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
6 #include "src/builtins/builtins-constructor.h" 8 #include "src/builtins/builtins-constructor.h"
7 #include "src/builtins/builtins-utils-gen.h" 9 #include "src/builtins/builtins-utils-gen.h"
8 #include "src/builtins/builtins.h" 10 #include "src/builtins/builtins.h"
9 #include "src/code-factory.h" 11 #include "src/code-factory.h"
10 #include "src/code-stub-assembler.h" 12 #include "src/code-stub-assembler.h"
11 #include "src/counters.h" 13 #include "src/counters.h"
12 #include "src/interface-descriptors.h" 14 #include "src/interface-descriptors.h"
13 #include "src/objects-inl.h" 15 #include "src/objects-inl.h"
14 16
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 325
324 Bind(&end); 326 Bind(&end);
325 return object; 327 return object;
326 } 328 }
327 329
328 Node* ConstructorBuiltinsAssembler::EmitFastNewFunctionContext( 330 Node* ConstructorBuiltinsAssembler::EmitFastNewFunctionContext(
329 Node* function, Node* slots, Node* context, ScopeType scope_type) { 331 Node* function, Node* slots, Node* context, ScopeType scope_type) {
330 slots = ChangeUint32ToWord(slots); 332 slots = ChangeUint32ToWord(slots);
331 333
332 // TODO(ishell): Use CSA::OptimalParameterMode() here. 334 // TODO(ishell): Use CSA::OptimalParameterMode() here.
333 CodeStubAssembler::ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; 335 ParameterMode mode = INTPTR_PARAMETERS;
334 Node* min_context_slots = IntPtrConstant(Context::MIN_CONTEXT_SLOTS); 336 Node* min_context_slots = IntPtrConstant(Context::MIN_CONTEXT_SLOTS);
335 Node* length = IntPtrAdd(slots, min_context_slots); 337 Node* length = IntPtrAdd(slots, min_context_slots);
336 Node* size = GetFixedArrayAllocationSize(length, FAST_ELEMENTS, mode); 338 Node* size = GetFixedArrayAllocationSize(length, FAST_ELEMENTS, mode);
337 339
338 // Create a new closure from the given function info in new space 340 // Create a new closure from the given function info in new space
339 Node* function_context = AllocateInNewSpace(size); 341 Node* function_context = AllocateInNewSpace(size);
340 342
341 Heap::RootListIndex context_type; 343 Heap::RootListIndex context_type;
342 switch (scope_type) { 344 switch (scope_type) {
343 case EVAL_SCOPE: 345 case EVAL_SCOPE:
(...skipping 28 matching lines...) Expand all
372 function_context, FAST_ELEMENTS, min_context_slots, length, 374 function_context, FAST_ELEMENTS, min_context_slots, length,
373 [this, undefined](Node* context, Node* offset) { 375 [this, undefined](Node* context, Node* offset) {
374 StoreNoWriteBarrier(MachineRepresentation::kTagged, context, offset, 376 StoreNoWriteBarrier(MachineRepresentation::kTagged, context, offset,
375 undefined); 377 undefined);
376 }, 378 },
377 mode); 379 mode);
378 380
379 return function_context; 381 return function_context;
380 } 382 }
381 383
382 // static
383 int ConstructorBuiltinsAssembler::MaximumFunctionContextSlots() {
384 return FLAG_test_small_max_function_context_stub_size ? kSmallMaximumSlots
385 : kMaximumSlots;
386 }
387
388 TF_BUILTIN(FastNewFunctionContextEval, ConstructorBuiltinsAssembler) { 384 TF_BUILTIN(FastNewFunctionContextEval, ConstructorBuiltinsAssembler) {
389 Node* function = Parameter(FastNewFunctionContextDescriptor::kFunction); 385 Node* function = Parameter(FastNewFunctionContextDescriptor::kFunction);
390 Node* slots = Parameter(FastNewFunctionContextDescriptor::kSlots); 386 Node* slots = Parameter(FastNewFunctionContextDescriptor::kSlots);
391 Node* context = Parameter(FastNewFunctionContextDescriptor::kContext); 387 Node* context = Parameter(FastNewFunctionContextDescriptor::kContext);
392 Return(EmitFastNewFunctionContext(function, slots, context, 388 Return(EmitFastNewFunctionContext(function, slots, context,
393 ScopeType::EVAL_SCOPE)); 389 ScopeType::EVAL_SCOPE));
394 } 390 }
395 391
396 TF_BUILTIN(FastNewFunctionContextFunction, ConstructorBuiltinsAssembler) { 392 TF_BUILTIN(FastNewFunctionContextFunction, ConstructorBuiltinsAssembler) {
397 Node* function = Parameter(FastNewFunctionContextDescriptor::kFunction); 393 Node* function = Parameter(FastNewFunctionContextDescriptor::kFunction);
398 Node* slots = Parameter(FastNewFunctionContextDescriptor::kSlots); 394 Node* slots = Parameter(FastNewFunctionContextDescriptor::kSlots);
399 Node* context = Parameter(FastNewFunctionContextDescriptor::kContext); 395 Node* context = Parameter(FastNewFunctionContextDescriptor::kContext);
400 Return(EmitFastNewFunctionContext(function, slots, context, 396 Return(EmitFastNewFunctionContext(function, slots, context,
401 ScopeType::FUNCTION_SCOPE)); 397 ScopeType::FUNCTION_SCOPE));
402 } 398 }
403 399
404 Node* ConstructorBuiltinsAssembler::EmitFastCloneRegExp(Node* closure, 400 Node* ConstructorBuiltinsAssembler::EmitFastCloneRegExp(Node* closure,
405 Node* literal_index, 401 Node* literal_index,
406 Node* pattern, 402 Node* pattern,
407 Node* flags, 403 Node* flags,
408 Node* context) { 404 Node* context) {
409 typedef CodeStubAssembler::Label Label;
410 typedef CodeStubAssembler::Variable Variable;
411 typedef compiler::Node Node;
412
413 Label call_runtime(this, Label::kDeferred), end(this); 405 Label call_runtime(this, Label::kDeferred), end(this);
414 406
415 Variable result(this, MachineRepresentation::kTagged); 407 Variable result(this, MachineRepresentation::kTagged);
416 408
417 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset); 409 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset);
418 Node* feedback_vector = LoadObjectField(cell, Cell::kValueOffset); 410 Node* feedback_vector = LoadObjectField(cell, Cell::kValueOffset);
419 Node* boilerplate = LoadFixedArrayElement(feedback_vector, literal_index, 0, 411 Node* boilerplate = LoadFixedArrayElement(feedback_vector, literal_index, 0,
420 CodeStubAssembler::SMI_PARAMETERS); 412 CodeStubAssembler::SMI_PARAMETERS);
421 GotoIf(IsUndefined(boilerplate), &call_runtime); 413 GotoIf(IsUndefined(boilerplate), &call_runtime);
422 414
(...skipping 25 matching lines...) Expand all
448 Node* pattern = Parameter(FastCloneRegExpDescriptor::kPattern); 440 Node* pattern = Parameter(FastCloneRegExpDescriptor::kPattern);
449 Node* flags = Parameter(FastCloneRegExpDescriptor::kFlags); 441 Node* flags = Parameter(FastCloneRegExpDescriptor::kFlags);
450 Node* context = Parameter(FastCloneRegExpDescriptor::kContext); 442 Node* context = Parameter(FastCloneRegExpDescriptor::kContext);
451 443
452 Return(EmitFastCloneRegExp(closure, literal_index, pattern, flags, context)); 444 Return(EmitFastCloneRegExp(closure, literal_index, pattern, flags, context));
453 } 445 }
454 446
455 Node* ConstructorBuiltinsAssembler::NonEmptyShallowClone( 447 Node* ConstructorBuiltinsAssembler::NonEmptyShallowClone(
456 Node* boilerplate, Node* boilerplate_map, Node* boilerplate_elements, 448 Node* boilerplate, Node* boilerplate_map, Node* boilerplate_elements,
457 Node* allocation_site, Node* capacity, ElementsKind kind) { 449 Node* allocation_site, Node* capacity, ElementsKind kind) {
458 typedef CodeStubAssembler::ParameterMode ParameterMode;
459
460 ParameterMode param_mode = OptimalParameterMode(); 450 ParameterMode param_mode = OptimalParameterMode();
461 451
462 Node* length = LoadJSArrayLength(boilerplate); 452 Node* length = LoadJSArrayLength(boilerplate);
463 capacity = TaggedToParameter(capacity, param_mode); 453 capacity = TaggedToParameter(capacity, param_mode);
464 454
465 Node *array, *elements; 455 Node *array, *elements;
466 std::tie(array, elements) = AllocateUninitializedJSArrayWithElements( 456 std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
467 kind, boilerplate_map, length, allocation_site, capacity, param_mode); 457 kind, boilerplate_map, length, allocation_site, capacity, param_mode);
468 458
469 Comment("copy elements header"); 459 Comment("copy elements header");
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 result.Bind(array); 572 result.Bind(array);
583 Goto(&return_result); 573 Goto(&return_result);
584 } 574 }
585 575
586 Bind(&return_result); 576 Bind(&return_result);
587 return result.value(); 577 return result.value();
588 } 578 }
589 579
590 void ConstructorBuiltinsAssembler::CreateFastCloneShallowArrayBuiltin( 580 void ConstructorBuiltinsAssembler::CreateFastCloneShallowArrayBuiltin(
591 AllocationSiteMode allocation_site_mode) { 581 AllocationSiteMode allocation_site_mode) {
592 typedef compiler::Node Node;
593 typedef CodeStubAssembler::Label Label;
594
595 Node* closure = Parameter(FastCloneShallowArrayDescriptor::kClosure); 582 Node* closure = Parameter(FastCloneShallowArrayDescriptor::kClosure);
596 Node* literal_index = 583 Node* literal_index =
597 Parameter(FastCloneShallowArrayDescriptor::kLiteralIndex); 584 Parameter(FastCloneShallowArrayDescriptor::kLiteralIndex);
598 Node* constant_elements = 585 Node* constant_elements =
599 Parameter(FastCloneShallowArrayDescriptor::kConstantElements); 586 Parameter(FastCloneShallowArrayDescriptor::kConstantElements);
600 Node* context = Parameter(FastCloneShallowArrayDescriptor::kContext); 587 Node* context = Parameter(FastCloneShallowArrayDescriptor::kContext);
601 Label call_runtime(this, Label::kDeferred); 588 Label call_runtime(this, Label::kDeferred);
602 Return(EmitFastCloneShallowArray(closure, literal_index, context, 589 Return(EmitFastCloneShallowArray(closure, literal_index, context,
603 &call_runtime, allocation_site_mode)); 590 &call_runtime, allocation_site_mode));
604 591
(...skipping 11 matching lines...) Expand all
616 } 603 }
617 604
618 TF_BUILTIN(FastCloneShallowArrayTrack, ConstructorBuiltinsAssembler) { 605 TF_BUILTIN(FastCloneShallowArrayTrack, ConstructorBuiltinsAssembler) {
619 CreateFastCloneShallowArrayBuiltin(TRACK_ALLOCATION_SITE); 606 CreateFastCloneShallowArrayBuiltin(TRACK_ALLOCATION_SITE);
620 } 607 }
621 608
622 TF_BUILTIN(FastCloneShallowArrayDontTrack, ConstructorBuiltinsAssembler) { 609 TF_BUILTIN(FastCloneShallowArrayDontTrack, ConstructorBuiltinsAssembler) {
623 CreateFastCloneShallowArrayBuiltin(DONT_TRACK_ALLOCATION_SITE); 610 CreateFastCloneShallowArrayBuiltin(DONT_TRACK_ALLOCATION_SITE);
624 } 611 }
625 612
626 // static
627 int ConstructorBuiltinsAssembler::FastCloneShallowObjectPropertiesCount(
628 int literal_length) {
629 // This heuristic of setting empty literals to have
630 // kInitialGlobalObjectUnusedPropertiesCount must remain in-sync with the
631 // runtime.
632 // TODO(verwaest): Unify this with the heuristic in the runtime.
633 return literal_length == 0
634 ? JSObject::kInitialGlobalObjectUnusedPropertiesCount
635 : literal_length;
636 }
637
638 Node* ConstructorBuiltinsAssembler::EmitFastCloneShallowObject( 613 Node* ConstructorBuiltinsAssembler::EmitFastCloneShallowObject(
639 Label* call_runtime, Node* closure, Node* literals_index, 614 Label* call_runtime, Node* closure, Node* literals_index,
640 Node* properties_count) { 615 Node* properties_count) {
641 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset); 616 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset);
642 Node* feedback_vector = LoadObjectField(cell, Cell::kValueOffset); 617 Node* feedback_vector = LoadObjectField(cell, Cell::kValueOffset);
643 Node* allocation_site = LoadFixedArrayElement( 618 Node* allocation_site = LoadFixedArrayElement(
644 feedback_vector, literals_index, 0, CodeStubAssembler::SMI_PARAMETERS); 619 feedback_vector, literals_index, 0, CodeStubAssembler::SMI_PARAMETERS);
645 GotoIf(IsUndefined(allocation_site), call_runtime); 620 GotoIf(IsUndefined(allocation_site), call_runtime);
646 621
647 // Calculate the object and allocation size based on the properties count. 622 // Calculate the object and allocation size based on the properties count.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 memento_create_count); 673 memento_create_count);
699 } 674 }
700 675
701 // TODO(verwaest): Allocate and fill in double boxes. 676 // TODO(verwaest): Allocate and fill in double boxes.
702 return copy; 677 return copy;
703 } 678 }
704 679
705 void ConstructorBuiltinsAssembler::CreateFastCloneShallowObjectBuiltin( 680 void ConstructorBuiltinsAssembler::CreateFastCloneShallowObjectBuiltin(
706 int properties_count) { 681 int properties_count) {
707 DCHECK_GE(properties_count, 0); 682 DCHECK_GE(properties_count, 0);
708 DCHECK_LE(properties_count, kMaximumClonedShallowObjectProperties); 683 DCHECK_LE(properties_count,
684 ConstructorBuiltins::kMaximumClonedShallowObjectProperties);
709 Label call_runtime(this); 685 Label call_runtime(this);
710 Node* closure = Parameter(0); 686 Node* closure = Parameter(0);
711 Node* literals_index = Parameter(1); 687 Node* literals_index = Parameter(1);
712 688
713 Node* properties_count_node = 689 Node* properties_count_node =
714 IntPtrConstant(FastCloneShallowObjectPropertiesCount(properties_count)); 690 IntPtrConstant(ConstructorBuiltins::FastCloneShallowObjectPropertiesCount(
691 properties_count));
715 Node* copy = EmitFastCloneShallowObject( 692 Node* copy = EmitFastCloneShallowObject(
716 &call_runtime, closure, literals_index, properties_count_node); 693 &call_runtime, closure, literals_index, properties_count_node);
717 Return(copy); 694 Return(copy);
718 695
719 Bind(&call_runtime); 696 Bind(&call_runtime);
720 Node* constant_properties = Parameter(2); 697 Node* constant_properties = Parameter(2);
721 Node* flags = Parameter(3); 698 Node* flags = Parameter(3);
722 Node* context = Parameter(4); 699 Node* context = Parameter(4);
723 TailCallRuntime(Runtime::kCreateObjectLiteral, context, closure, 700 TailCallRuntime(Runtime::kCreateObjectLiteral, context, closure,
724 literals_index, constant_properties, flags); 701 literals_index, constant_properties, flags);
725 } 702 }
726 703
727 #define SHALLOW_OBJECT_BUILTIN(props) \ 704 #define SHALLOW_OBJECT_BUILTIN(props) \
728 TF_BUILTIN(FastCloneShallowObject##props, ConstructorBuiltinsAssembler) { \ 705 TF_BUILTIN(FastCloneShallowObject##props, ConstructorBuiltinsAssembler) { \
729 CreateFastCloneShallowObjectBuiltin(props); \ 706 CreateFastCloneShallowObjectBuiltin(props); \
730 } 707 }
731 708
732 SHALLOW_OBJECT_BUILTIN(0); 709 SHALLOW_OBJECT_BUILTIN(0);
733 SHALLOW_OBJECT_BUILTIN(1); 710 SHALLOW_OBJECT_BUILTIN(1);
734 SHALLOW_OBJECT_BUILTIN(2); 711 SHALLOW_OBJECT_BUILTIN(2);
735 SHALLOW_OBJECT_BUILTIN(3); 712 SHALLOW_OBJECT_BUILTIN(3);
736 SHALLOW_OBJECT_BUILTIN(4); 713 SHALLOW_OBJECT_BUILTIN(4);
737 SHALLOW_OBJECT_BUILTIN(5); 714 SHALLOW_OBJECT_BUILTIN(5);
738 SHALLOW_OBJECT_BUILTIN(6); 715 SHALLOW_OBJECT_BUILTIN(6);
739 716
740 } // namespace internal 717 } // namespace internal
741 } // namespace v8 718 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-constructor-gen.h ('k') | src/builtins/builtins-forin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698