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

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

Issue 2674593003: [TypeFeedbackVector] Root feedback vectors at function literal site. (Closed)
Patch Set: REBASE+liveedit fix. Created 3 years, 10 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/arm64/builtins-arm64.cc ('k') | src/builtins/ia32/builtins-ia32.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/builtins/builtins-constructor.h" 5 #include "src/builtins/builtins-constructor.h"
6 #include "src/ast/ast.h" 6 #include "src/ast/ast.h"
7 #include "src/builtins/builtins-utils.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"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 113
114 // Get the function map in the current native context and set that 114 // Get the function map in the current native context and set that
115 // as the map of the allocated object. 115 // as the map of the allocated object.
116 Node* native_context = LoadNativeContext(context); 116 Node* native_context = LoadNativeContext(context);
117 Node* map_slot_value = 117 Node* map_slot_value =
118 LoadFixedArrayElement(native_context, map_index.value()); 118 LoadFixedArrayElement(native_context, map_index.value());
119 StoreMapNoWriteBarrier(result, map_slot_value); 119 StoreMapNoWriteBarrier(result, map_slot_value);
120 120
121 // Initialize the rest of the function. 121 // Initialize the rest of the function.
122 Node* empty_fixed_array = HeapConstant(factory->empty_fixed_array()); 122 Node* empty_fixed_array = HeapConstant(factory->empty_fixed_array());
123 Node* empty_feedback_vector =
124 HeapConstant(factory->empty_type_feedback_vector());
125 StoreObjectFieldNoWriteBarrier(result, JSObject::kPropertiesOffset, 123 StoreObjectFieldNoWriteBarrier(result, JSObject::kPropertiesOffset,
126 empty_fixed_array); 124 empty_fixed_array);
127 StoreObjectFieldNoWriteBarrier(result, JSObject::kElementsOffset, 125 StoreObjectFieldNoWriteBarrier(result, JSObject::kElementsOffset,
128 empty_fixed_array); 126 empty_fixed_array);
127 Node* literals_cell = LoadFixedArrayElement(
128 feedback_vector, slot, 0, CodeStubAssembler::SMI_PARAMETERS);
129 StoreObjectFieldNoWriteBarrier(result, JSFunction::kFeedbackVectorOffset, 129 StoreObjectFieldNoWriteBarrier(result, JSFunction::kFeedbackVectorOffset,
130 empty_feedback_vector); 130 literals_cell);
131 StoreObjectFieldNoWriteBarrier( 131 StoreObjectFieldNoWriteBarrier(
132 result, JSFunction::kPrototypeOrInitialMapOffset, TheHoleConstant()); 132 result, JSFunction::kPrototypeOrInitialMapOffset, TheHoleConstant());
133 StoreObjectFieldNoWriteBarrier(result, JSFunction::kSharedFunctionInfoOffset, 133 StoreObjectFieldNoWriteBarrier(result, JSFunction::kSharedFunctionInfoOffset,
134 shared_info); 134 shared_info);
135 StoreObjectFieldNoWriteBarrier(result, JSFunction::kContextOffset, context); 135 StoreObjectFieldNoWriteBarrier(result, JSFunction::kContextOffset, context);
136 Handle<Code> lazy_builtin_handle( 136 Handle<Code> lazy_builtin_handle(
137 isolate->builtins()->builtin(Builtins::kCompileLazy)); 137 isolate->builtins()->builtin(Builtins::kCompileLazy));
138 Node* lazy_builtin = HeapConstant(lazy_builtin_handle); 138 Node* lazy_builtin = HeapConstant(lazy_builtin_handle);
139 Node* lazy_builtin_entry = 139 Node* lazy_builtin_entry =
140 IntPtrAdd(BitcastTaggedToWord(lazy_builtin), 140 IntPtrAdd(BitcastTaggedToWord(lazy_builtin),
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 Node* flags, 394 Node* flags,
395 Node* context) { 395 Node* context) {
396 typedef CodeStubAssembler::Label Label; 396 typedef CodeStubAssembler::Label Label;
397 typedef CodeStubAssembler::Variable Variable; 397 typedef CodeStubAssembler::Variable Variable;
398 typedef compiler::Node Node; 398 typedef compiler::Node Node;
399 399
400 Label call_runtime(this, Label::kDeferred), end(this); 400 Label call_runtime(this, Label::kDeferred), end(this);
401 401
402 Variable result(this, MachineRepresentation::kTagged); 402 Variable result(this, MachineRepresentation::kTagged);
403 403
404 Node* vector_array = 404 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset);
405 LoadObjectField(closure, JSFunction::kFeedbackVectorOffset); 405 Node* literals_array = LoadObjectField(cell, Cell::kValueOffset);
406 Node* boilerplate = LoadFixedArrayElement(vector_array, literal_index, 0, 406 Node* boilerplate = LoadFixedArrayElement(literals_array, literal_index, 0,
407 CodeStubAssembler::SMI_PARAMETERS); 407 CodeStubAssembler::SMI_PARAMETERS);
408 GotoIf(IsUndefined(boilerplate), &call_runtime); 408 GotoIf(IsUndefined(boilerplate), &call_runtime);
409 409
410 { 410 {
411 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; 411 int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
412 Node* copy = Allocate(size); 412 Node* copy = Allocate(size);
413 for (int offset = 0; offset < size; offset += kPointerSize) { 413 for (int offset = 0; offset < size; offset += kPointerSize) {
414 Node* value = LoadObjectField(boilerplate, offset); 414 Node* value = LoadObjectField(boilerplate, offset);
415 StoreObjectFieldNoWriteBarrier(copy, offset, value); 415 StoreObjectFieldNoWriteBarrier(copy, offset, value);
416 } 416 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 Node* closure, Node* literal_index, Node* context, 477 Node* closure, Node* literal_index, Node* context,
478 CodeAssemblerLabel* call_runtime, AllocationSiteMode allocation_site_mode) { 478 CodeAssemblerLabel* call_runtime, AllocationSiteMode allocation_site_mode) {
479 typedef CodeStubAssembler::Label Label; 479 typedef CodeStubAssembler::Label Label;
480 typedef CodeStubAssembler::Variable Variable; 480 typedef CodeStubAssembler::Variable Variable;
481 typedef compiler::Node Node; 481 typedef compiler::Node Node;
482 482
483 Label zero_capacity(this), cow_elements(this), fast_elements(this), 483 Label zero_capacity(this), cow_elements(this), fast_elements(this),
484 return_result(this); 484 return_result(this);
485 Variable result(this, MachineRepresentation::kTagged); 485 Variable result(this, MachineRepresentation::kTagged);
486 486
487 Node* vector_array = 487 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset);
488 LoadObjectField(closure, JSFunction::kFeedbackVectorOffset); 488 Node* literals_array = LoadObjectField(cell, Cell::kValueOffset);
489 Node* allocation_site = LoadFixedArrayElement( 489 Node* allocation_site = LoadFixedArrayElement(
490 vector_array, literal_index, 0, CodeStubAssembler::SMI_PARAMETERS); 490 literals_array, literal_index, 0, CodeStubAssembler::SMI_PARAMETERS);
491 491
492 GotoIf(IsUndefined(allocation_site), call_runtime); 492 GotoIf(IsUndefined(allocation_site), call_runtime);
493 allocation_site = LoadFixedArrayElement(vector_array, literal_index, 0, 493 allocation_site = LoadFixedArrayElement(literals_array, literal_index, 0,
494 CodeStubAssembler::SMI_PARAMETERS); 494 CodeStubAssembler::SMI_PARAMETERS);
495 495
496 Node* boilerplate = 496 Node* boilerplate =
497 LoadObjectField(allocation_site, AllocationSite::kTransitionInfoOffset); 497 LoadObjectField(allocation_site, AllocationSite::kTransitionInfoOffset);
498 Node* boilerplate_map = LoadMap(boilerplate); 498 Node* boilerplate_map = LoadMap(boilerplate);
499 Node* boilerplate_elements = LoadElements(boilerplate); 499 Node* boilerplate_elements = LoadElements(boilerplate);
500 Node* capacity = LoadFixedArrayBaseLength(boilerplate_elements); 500 Node* capacity = LoadFixedArrayBaseLength(boilerplate_elements);
501 allocation_site = 501 allocation_site =
502 allocation_site_mode == TRACK_ALLOCATION_SITE ? allocation_site : nullptr; 502 allocation_site_mode == TRACK_ALLOCATION_SITE ? allocation_site : nullptr;
503 503
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 // runtime. 635 // runtime.
636 // TODO(verwaest): Unify this with the heuristic in the runtime. 636 // TODO(verwaest): Unify this with the heuristic in the runtime.
637 return literal_length == 0 637 return literal_length == 0
638 ? JSObject::kInitialGlobalObjectUnusedPropertiesCount 638 ? JSObject::kInitialGlobalObjectUnusedPropertiesCount
639 : literal_length; 639 : literal_length;
640 } 640 }
641 641
642 Node* ConstructorBuiltinsAssembler::EmitFastCloneShallowObject( 642 Node* ConstructorBuiltinsAssembler::EmitFastCloneShallowObject(
643 CodeAssemblerLabel* call_runtime, Node* closure, Node* literals_index, 643 CodeAssemblerLabel* call_runtime, Node* closure, Node* literals_index,
644 Node* properties_count) { 644 Node* properties_count) {
645 Node* vector_array = 645 Node* cell = LoadObjectField(closure, JSFunction::kFeedbackVectorOffset);
646 LoadObjectField(closure, JSFunction::kFeedbackVectorOffset); 646 Node* literals_array = LoadObjectField(cell, Cell::kValueOffset);
647 Node* allocation_site = LoadFixedArrayElement( 647 Node* allocation_site = LoadFixedArrayElement(
648 vector_array, literals_index, 0, CodeStubAssembler::SMI_PARAMETERS); 648 literals_array, literals_index, 0, CodeStubAssembler::SMI_PARAMETERS);
649 GotoIf(IsUndefined(allocation_site), call_runtime); 649 GotoIf(IsUndefined(allocation_site), call_runtime);
650 650
651 // Calculate the object and allocation size based on the properties count. 651 // Calculate the object and allocation size based on the properties count.
652 Node* object_size = IntPtrAdd(WordShl(properties_count, kPointerSizeLog2), 652 Node* object_size = IntPtrAdd(WordShl(properties_count, kPointerSizeLog2),
653 IntPtrConstant(JSObject::kHeaderSize)); 653 IntPtrConstant(JSObject::kHeaderSize));
654 Node* allocation_size = object_size; 654 Node* allocation_size = object_size;
655 if (FLAG_allocation_site_pretenuring) { 655 if (FLAG_allocation_site_pretenuring) {
656 allocation_size = 656 allocation_size =
657 IntPtrAdd(object_size, IntPtrConstant(AllocationMemento::kSize)); 657 IntPtrAdd(object_size, IntPtrConstant(AllocationMemento::kSize));
658 } 658 }
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 case 6: 759 case 6:
760 return FastCloneShallowObject6(); 760 return FastCloneShallowObject6();
761 default: 761 default:
762 UNREACHABLE(); 762 UNREACHABLE();
763 } 763 }
764 return Handle<Code>::null(); 764 return Handle<Code>::null();
765 } 765 }
766 766
767 } // namespace internal 767 } // namespace internal
768 } // namespace v8 768 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/arm64/builtins-arm64.cc ('k') | src/builtins/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698