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

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

Issue 2752143004: [refactor] Separate generated builtins and C++ builtins into separate files (Closed)
Patch Set: tentative gcmole fix 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.cc ('k') | src/builtins/builtins-conversion.cc » ('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/ast/ast.h"
5 #include "src/builtins/builtins-constructor.h" 6 #include "src/builtins/builtins-constructor.h"
6 #include "src/ast/ast.h" 7 #include "src/builtins/builtins-utils-gen.h"
7 #include "src/builtins/builtins-utils.h"
8 #include "src/builtins/builtins.h" 8 #include "src/builtins/builtins.h"
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/code-stub-assembler.h" 10 #include "src/code-stub-assembler.h"
11 #include "src/counters.h" 11 #include "src/counters.h"
12 #include "src/interface-descriptors.h" 12 #include "src/interface-descriptors.h"
13 #include "src/objects-inl.h" 13 #include "src/objects-inl.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 17
18 typedef compiler::Node Node; 18 typedef compiler::Node Node;
19 19
20 Node* ConstructorBuiltinsAssembler::EmitFastNewClosure(Node* shared_info, 20 Node* ConstructorBuiltinsAssembler::EmitFastNewClosure(Node* shared_info,
21 Node* feedback_vector, 21 Node* feedback_vector,
22 Node* slot, 22 Node* slot,
23 Node* context) { 23 Node* context) {
24 typedef compiler::CodeAssembler::Label Label;
25 typedef compiler::CodeAssembler::Variable Variable;
26
27 Isolate* isolate = this->isolate(); 24 Isolate* isolate = this->isolate();
28 Factory* factory = isolate->factory(); 25 Factory* factory = isolate->factory();
29 IncrementCounter(isolate->counters()->fast_new_closure_total(), 1); 26 IncrementCounter(isolate->counters()->fast_new_closure_total(), 1);
30 27
31 // Create a new closure from the given function info in new space 28 // Create a new closure from the given function info in new space
32 Node* result = Allocate(JSFunction::kSize); 29 Node* result = Allocate(JSFunction::kSize);
33 30
34 // Calculate the index of the map we should install on the function based on 31 // Calculate the index of the map we should install on the function based on
35 // the FunctionKind and LanguageMode of the function. 32 // the FunctionKind and LanguageMode of the function.
36 // Note: Must be kept in sync with Context::FunctionMapIndex 33 // Note: Must be kept in sync with Context::FunctionMapIndex
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 Goto(&end); 201 Goto(&end);
205 202
206 Bind(&call_runtime); 203 Bind(&call_runtime);
207 var_obj.Bind(CallRuntime(Runtime::kNewObject, context, target, new_target)); 204 var_obj.Bind(CallRuntime(Runtime::kNewObject, context, target, new_target));
208 Goto(&end); 205 Goto(&end);
209 206
210 Bind(&end); 207 Bind(&end);
211 return var_obj.value(); 208 return var_obj.value();
212 } 209 }
213 210
214 Node* ConstructorBuiltinsAssembler::EmitFastNewObject( 211 Node* ConstructorBuiltinsAssembler::EmitFastNewObject(Node* context,
215 Node* context, Node* target, Node* new_target, 212 Node* target,
216 CodeAssemblerLabel* call_runtime) { 213 Node* new_target,
214 Label* call_runtime) {
217 CSA_ASSERT(this, HasInstanceType(target, JS_FUNCTION_TYPE)); 215 CSA_ASSERT(this, HasInstanceType(target, JS_FUNCTION_TYPE));
218 CSA_ASSERT(this, IsJSReceiver(new_target)); 216 CSA_ASSERT(this, IsJSReceiver(new_target));
219 217
220 // Verify that the new target is a JSFunction. 218 // Verify that the new target is a JSFunction.
221 Label fast(this), end(this); 219 Label fast(this), end(this);
222 GotoIf(HasInstanceType(new_target, JS_FUNCTION_TYPE), &fast); 220 GotoIf(HasInstanceType(new_target, JS_FUNCTION_TYPE), &fast);
223 Goto(call_runtime); 221 Goto(call_runtime);
224 222
225 Bind(&fast); 223 Bind(&fast);
226 224
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 394 }
397 395
398 TF_BUILTIN(FastNewFunctionContextFunction, ConstructorBuiltinsAssembler) { 396 TF_BUILTIN(FastNewFunctionContextFunction, ConstructorBuiltinsAssembler) {
399 Node* function = Parameter(FastNewFunctionContextDescriptor::kFunction); 397 Node* function = Parameter(FastNewFunctionContextDescriptor::kFunction);
400 Node* slots = Parameter(FastNewFunctionContextDescriptor::kSlots); 398 Node* slots = Parameter(FastNewFunctionContextDescriptor::kSlots);
401 Node* context = Parameter(FastNewFunctionContextDescriptor::kContext); 399 Node* context = Parameter(FastNewFunctionContextDescriptor::kContext);
402 Return(EmitFastNewFunctionContext(function, slots, context, 400 Return(EmitFastNewFunctionContext(function, slots, context,
403 ScopeType::FUNCTION_SCOPE)); 401 ScopeType::FUNCTION_SCOPE));
404 } 402 }
405 403
406 Handle<Code> Builtins::NewFunctionContext(ScopeType scope_type) {
407 switch (scope_type) {
408 case ScopeType::EVAL_SCOPE:
409 return FastNewFunctionContextEval();
410 case ScopeType::FUNCTION_SCOPE:
411 return FastNewFunctionContextFunction();
412 default:
413 UNREACHABLE();
414 }
415 return Handle<Code>::null();
416 }
417
418 Node* ConstructorBuiltinsAssembler::EmitFastCloneRegExp(Node* closure, 404 Node* ConstructorBuiltinsAssembler::EmitFastCloneRegExp(Node* closure,
419 Node* literal_index, 405 Node* literal_index,
420 Node* pattern, 406 Node* pattern,
421 Node* flags, 407 Node* flags,
422 Node* context) { 408 Node* context) {
423 typedef CodeStubAssembler::Label Label; 409 typedef CodeStubAssembler::Label Label;
424 typedef CodeStubAssembler::Variable Variable; 410 typedef CodeStubAssembler::Variable Variable;
425 typedef compiler::Node Node; 411 typedef compiler::Node Node;
426 412
427 Label call_runtime(this, Label::kDeferred), end(this); 413 Label call_runtime(this, Label::kDeferred), end(this);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 480
495 Comment("copy boilerplate elements"); 481 Comment("copy boilerplate elements");
496 CopyFixedArrayElements(kind, boilerplate_elements, elements, length, 482 CopyFixedArrayElements(kind, boilerplate_elements, elements, length,
497 SKIP_WRITE_BARRIER, param_mode); 483 SKIP_WRITE_BARRIER, param_mode);
498 IncrementCounter(isolate()->counters()->inlined_copied_elements(), 1); 484 IncrementCounter(isolate()->counters()->inlined_copied_elements(), 1);
499 485
500 return array; 486 return array;
501 } 487 }
502 488
503 Node* ConstructorBuiltinsAssembler::EmitFastCloneShallowArray( 489 Node* ConstructorBuiltinsAssembler::EmitFastCloneShallowArray(
504 Node* closure, Node* literal_index, Node* context, 490 Node* closure, Node* literal_index, Node* context, Label* call_runtime,
505 CodeAssemblerLabel* call_runtime, AllocationSiteMode allocation_site_mode) { 491 AllocationSiteMode allocation_site_mode) {
506 typedef CodeStubAssembler::Label Label;
507 typedef CodeStubAssembler::Variable Variable;
508 typedef compiler::Node Node;
509
510 Label zero_capacity(this), cow_elements(this), fast_elements(this), 492 Label zero_capacity(this), cow_elements(this), fast_elements(this),
511 return_result(this); 493 return_result(this);
512 Variable result(this, MachineRepresentation::kTagged); 494 Variable result(this, MachineRepresentation::kTagged);
513 495
514 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset); 496 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset);
515 Node* feedback_vector = LoadObjectField(cell, Cell::kValueOffset); 497 Node* feedback_vector = LoadObjectField(cell, Cell::kValueOffset);
516 Node* allocation_site = LoadFixedArrayElement( 498 Node* allocation_site = LoadFixedArrayElement(
517 feedback_vector, literal_index, 0, CodeStubAssembler::SMI_PARAMETERS); 499 feedback_vector, literal_index, 0, CodeStubAssembler::SMI_PARAMETERS);
518 500
519 GotoIf(IsUndefined(allocation_site), call_runtime); 501 GotoIf(IsUndefined(allocation_site), call_runtime);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 } 616 }
635 617
636 TF_BUILTIN(FastCloneShallowArrayTrack, ConstructorBuiltinsAssembler) { 618 TF_BUILTIN(FastCloneShallowArrayTrack, ConstructorBuiltinsAssembler) {
637 CreateFastCloneShallowArrayBuiltin(TRACK_ALLOCATION_SITE); 619 CreateFastCloneShallowArrayBuiltin(TRACK_ALLOCATION_SITE);
638 } 620 }
639 621
640 TF_BUILTIN(FastCloneShallowArrayDontTrack, ConstructorBuiltinsAssembler) { 622 TF_BUILTIN(FastCloneShallowArrayDontTrack, ConstructorBuiltinsAssembler) {
641 CreateFastCloneShallowArrayBuiltin(DONT_TRACK_ALLOCATION_SITE); 623 CreateFastCloneShallowArrayBuiltin(DONT_TRACK_ALLOCATION_SITE);
642 } 624 }
643 625
644 Handle<Code> Builtins::NewCloneShallowArray(
645 AllocationSiteMode allocation_mode) {
646 switch (allocation_mode) {
647 case TRACK_ALLOCATION_SITE:
648 return FastCloneShallowArrayTrack();
649 case DONT_TRACK_ALLOCATION_SITE:
650 return FastCloneShallowArrayDontTrack();
651 default:
652 UNREACHABLE();
653 }
654 return Handle<Code>::null();
655 }
656
657 // static 626 // static
658 int ConstructorBuiltinsAssembler::FastCloneShallowObjectPropertiesCount( 627 int ConstructorBuiltinsAssembler::FastCloneShallowObjectPropertiesCount(
659 int literal_length) { 628 int literal_length) {
660 // This heuristic of setting empty literals to have 629 // This heuristic of setting empty literals to have
661 // kInitialGlobalObjectUnusedPropertiesCount must remain in-sync with the 630 // kInitialGlobalObjectUnusedPropertiesCount must remain in-sync with the
662 // runtime. 631 // runtime.
663 // TODO(verwaest): Unify this with the heuristic in the runtime. 632 // TODO(verwaest): Unify this with the heuristic in the runtime.
664 return literal_length == 0 633 return literal_length == 0
665 ? JSObject::kInitialGlobalObjectUnusedPropertiesCount 634 ? JSObject::kInitialGlobalObjectUnusedPropertiesCount
666 : literal_length; 635 : literal_length;
667 } 636 }
668 637
669 Node* ConstructorBuiltinsAssembler::EmitFastCloneShallowObject( 638 Node* ConstructorBuiltinsAssembler::EmitFastCloneShallowObject(
670 CodeAssemblerLabel* call_runtime, Node* closure, Node* literals_index, 639 Label* call_runtime, Node* closure, Node* literals_index,
671 Node* properties_count) { 640 Node* properties_count) {
672 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset); 641 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset);
673 Node* feedback_vector = LoadObjectField(cell, Cell::kValueOffset); 642 Node* feedback_vector = LoadObjectField(cell, Cell::kValueOffset);
674 Node* allocation_site = LoadFixedArrayElement( 643 Node* allocation_site = LoadFixedArrayElement(
675 feedback_vector, literals_index, 0, CodeStubAssembler::SMI_PARAMETERS); 644 feedback_vector, literals_index, 0, CodeStubAssembler::SMI_PARAMETERS);
676 GotoIf(IsUndefined(allocation_site), call_runtime); 645 GotoIf(IsUndefined(allocation_site), call_runtime);
677 646
678 // Calculate the object and allocation size based on the properties count. 647 // Calculate the object and allocation size based on the properties count.
679 Node* object_size = IntPtrAdd(WordShl(properties_count, kPointerSizeLog2), 648 Node* object_size = IntPtrAdd(WordShl(properties_count, kPointerSizeLog2),
680 IntPtrConstant(JSObject::kHeaderSize)); 649 IntPtrConstant(JSObject::kHeaderSize));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 } 730 }
762 731
763 SHALLOW_OBJECT_BUILTIN(0); 732 SHALLOW_OBJECT_BUILTIN(0);
764 SHALLOW_OBJECT_BUILTIN(1); 733 SHALLOW_OBJECT_BUILTIN(1);
765 SHALLOW_OBJECT_BUILTIN(2); 734 SHALLOW_OBJECT_BUILTIN(2);
766 SHALLOW_OBJECT_BUILTIN(3); 735 SHALLOW_OBJECT_BUILTIN(3);
767 SHALLOW_OBJECT_BUILTIN(4); 736 SHALLOW_OBJECT_BUILTIN(4);
768 SHALLOW_OBJECT_BUILTIN(5); 737 SHALLOW_OBJECT_BUILTIN(5);
769 SHALLOW_OBJECT_BUILTIN(6); 738 SHALLOW_OBJECT_BUILTIN(6);
770 739
771 Handle<Code> Builtins::NewCloneShallowObject(int length) {
772 switch (length) {
773 case 0:
774 return FastCloneShallowObject0();
775 case 1:
776 return FastCloneShallowObject1();
777 case 2:
778 return FastCloneShallowObject2();
779 case 3:
780 return FastCloneShallowObject3();
781 case 4:
782 return FastCloneShallowObject4();
783 case 5:
784 return FastCloneShallowObject5();
785 case 6:
786 return FastCloneShallowObject6();
787 default:
788 UNREACHABLE();
789 }
790 return Handle<Code>::null();
791 }
792
793 } // namespace internal 740 } // namespace internal
794 } // namespace v8 741 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-constructor.cc ('k') | src/builtins/builtins-conversion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698