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

Side by Side Diff: src/code-stubs.cc

Issue 2435023002: Use a different map to distinguish eval contexts (Closed)
Patch Set: Changes based on review commnets Created 4 years 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/code-stubs.h" 5 #include "src/code-stubs.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 2588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2599 void FastNewClosureStub::GenerateAssembly( 2599 void FastNewClosureStub::GenerateAssembly(
2600 compiler::CodeAssemblerState* state) const { 2600 compiler::CodeAssemblerState* state) const {
2601 typedef compiler::Node Node; 2601 typedef compiler::Node Node;
2602 CodeStubAssembler assembler(state); 2602 CodeStubAssembler assembler(state);
2603 Node* shared = assembler.Parameter(Descriptor::kSharedFunctionInfo); 2603 Node* shared = assembler.Parameter(Descriptor::kSharedFunctionInfo);
2604 Node* context = assembler.Parameter(Descriptor::kContext); 2604 Node* context = assembler.Parameter(Descriptor::kContext);
2605 assembler.Return(Generate(&assembler, shared, context)); 2605 assembler.Return(Generate(&assembler, shared, context));
2606 } 2606 }
2607 2607
2608 // static 2608 // static
2609 int FastNewFunctionContextStub::MaximumSlots() {
2610 return FLAG_test_small_max_function_context_stub_size ? kSmallMaximumSlots
2611 : kMaximumSlots;
2612 }
2613
2614 // static
2609 compiler::Node* FastNewFunctionContextStub::Generate( 2615 compiler::Node* FastNewFunctionContextStub::Generate(
2610 CodeStubAssembler* assembler, compiler::Node* function, 2616 CodeStubAssembler* assembler, compiler::Node* function,
2611 compiler::Node* slots, compiler::Node* context) { 2617 compiler::Node* slots, compiler::Node* context, ScopeType scope_type) {
2612 typedef compiler::Node Node; 2618 typedef compiler::Node Node;
2613 2619
2614 slots = assembler->ChangeUint32ToWord(slots); 2620 slots = assembler->ChangeUint32ToWord(slots);
2615 2621
2616 // TODO(ishell): Use CSA::OptimalParameterMode() here. 2622 // TODO(ishell): Use CSA::OptimalParameterMode() here.
2617 CodeStubAssembler::ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; 2623 CodeStubAssembler::ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS;
2618 Node* min_context_slots = 2624 Node* min_context_slots =
2619 assembler->IntPtrConstant(Context::MIN_CONTEXT_SLOTS); 2625 assembler->IntPtrConstant(Context::MIN_CONTEXT_SLOTS);
2620 Node* length = assembler->IntPtrAdd(slots, min_context_slots); 2626 Node* length = assembler->IntPtrAdd(slots, min_context_slots);
2621 Node* size = 2627 Node* size =
2622 assembler->GetFixedArrayAllocationSize(length, FAST_ELEMENTS, mode); 2628 assembler->GetFixedArrayAllocationSize(length, FAST_ELEMENTS, mode);
2623 2629
2624 // Create a new closure from the given function info in new space 2630 // Create a new closure from the given function info in new space
2625 Node* function_context = assembler->Allocate(size); 2631 Node* function_context = assembler->Allocate(size);
2626 2632
2627 assembler->StoreMapNoWriteBarrier(function_context, 2633 Heap::RootListIndex context_type;
2628 Heap::kFunctionContextMapRootIndex); 2634 switch (scope_type) {
2635 case EVAL_SCOPE:
2636 context_type = Heap::kEvalContextMapRootIndex;
2637 break;
2638 case FUNCTION_SCOPE:
2639 context_type = Heap::kFunctionContextMapRootIndex;
2640 break;
2641 default:
2642 UNREACHABLE();
2643 }
2644 assembler->StoreMapNoWriteBarrier(function_context, context_type);
2629 assembler->StoreObjectFieldNoWriteBarrier( 2645 assembler->StoreObjectFieldNoWriteBarrier(
2630 function_context, Context::kLengthOffset, assembler->SmiTag(length)); 2646 function_context, Context::kLengthOffset, assembler->SmiTag(length));
2631 2647
2632 // Set up the fixed slots. 2648 // Set up the fixed slots.
2633 assembler->StoreFixedArrayElement(function_context, Context::CLOSURE_INDEX, 2649 assembler->StoreFixedArrayElement(function_context, Context::CLOSURE_INDEX,
2634 function, SKIP_WRITE_BARRIER); 2650 function, SKIP_WRITE_BARRIER);
2635 assembler->StoreFixedArrayElement(function_context, Context::PREVIOUS_INDEX, 2651 assembler->StoreFixedArrayElement(function_context, Context::PREVIOUS_INDEX,
2636 context, SKIP_WRITE_BARRIER); 2652 context, SKIP_WRITE_BARRIER);
2637 assembler->StoreFixedArrayElement(function_context, Context::EXTENSION_INDEX, 2653 assembler->StoreFixedArrayElement(function_context, Context::EXTENSION_INDEX,
2638 assembler->TheHoleConstant(), 2654 assembler->TheHoleConstant(),
(...skipping 19 matching lines...) Expand all
2658 } 2674 }
2659 2675
2660 void FastNewFunctionContextStub::GenerateAssembly( 2676 void FastNewFunctionContextStub::GenerateAssembly(
2661 compiler::CodeAssemblerState* state) const { 2677 compiler::CodeAssemblerState* state) const {
2662 typedef compiler::Node Node; 2678 typedef compiler::Node Node;
2663 CodeStubAssembler assembler(state); 2679 CodeStubAssembler assembler(state);
2664 Node* function = assembler.Parameter(Descriptor::kFunction); 2680 Node* function = assembler.Parameter(Descriptor::kFunction);
2665 Node* slots = assembler.Parameter(Descriptor::kSlots); 2681 Node* slots = assembler.Parameter(Descriptor::kSlots);
2666 Node* context = assembler.Parameter(Descriptor::kContext); 2682 Node* context = assembler.Parameter(Descriptor::kContext);
2667 2683
2668 assembler.Return(Generate(&assembler, function, slots, context)); 2684 assembler.Return(
2685 Generate(&assembler, function, slots, context, scope_type()));
2669 } 2686 }
2670 2687
2671 // static 2688 // static
2672 compiler::Node* FastCloneRegExpStub::Generate(CodeStubAssembler* assembler, 2689 compiler::Node* FastCloneRegExpStub::Generate(CodeStubAssembler* assembler,
2673 compiler::Node* closure, 2690 compiler::Node* closure,
2674 compiler::Node* literal_index, 2691 compiler::Node* literal_index,
2675 compiler::Node* pattern, 2692 compiler::Node* pattern,
2676 compiler::Node* flags, 2693 compiler::Node* flags,
2677 compiler::Node* context) { 2694 compiler::Node* context) {
2678 typedef CodeStubAssembler::Label Label; 2695 typedef CodeStubAssembler::Label Label;
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
3220 } 3237 }
3221 3238
3222 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) 3239 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate)
3223 : PlatformCodeStub(isolate) {} 3240 : PlatformCodeStub(isolate) {}
3224 3241
3225 InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate) 3242 InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate)
3226 : PlatformCodeStub(isolate) {} 3243 : PlatformCodeStub(isolate) {}
3227 3244
3228 } // namespace internal 3245 } // namespace internal
3229 } // namespace v8 3246 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698