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

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

Issue 2435023002: Use a different map to distinguish eval contexts (Closed)
Patch Set: relax dchecks Created 4 years, 1 month 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 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after
2622 assembler->UndefinedConstant()); 2622 assembler->UndefinedConstant());
2623 2623
2624 return result; 2624 return result;
2625 } 2625 }
2626 2626
2627 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const { 2627 void FastNewClosureStub::GenerateAssembly(CodeStubAssembler* assembler) const {
2628 assembler->Return( 2628 assembler->Return(
2629 Generate(assembler, assembler->Parameter(0), assembler->Parameter(1))); 2629 Generate(assembler, assembler->Parameter(0), assembler->Parameter(1)));
2630 } 2630 }
2631 2631
2632 // static 2632 namespace {
2633 compiler::Node* FastNewFunctionContextStub::Generate( 2633
2634 CodeStubAssembler* assembler, compiler::Node* function, 2634 compiler::Node* GenerateFastNewFunctionContextStub(CodeStubAssembler* assembler,
2635 compiler::Node* slots, compiler::Node* context) { 2635 compiler::Node* function,
2636 compiler::Node* slots,
2637 compiler::Node* context,
2638 Handle<Map> map) {
2636 typedef compiler::Node Node; 2639 typedef compiler::Node Node;
2637 2640
2638 Node* min_context_slots = 2641 Node* min_context_slots =
2639 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS); 2642 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS);
2640 Node* length = assembler->Int32Add(slots, min_context_slots); 2643 Node* length = assembler->Int32Add(slots, min_context_slots);
2641 Node* size = assembler->Int32Add( 2644 Node* size = assembler->Int32Add(
2642 assembler->Word32Shl(length, assembler->Int32Constant(kPointerSizeLog2)), 2645 assembler->Word32Shl(length, assembler->Int32Constant(kPointerSizeLog2)),
2643 assembler->Int32Constant(FixedArray::kHeaderSize)); 2646 assembler->Int32Constant(FixedArray::kHeaderSize));
2644 2647
2645 // Create a new closure from the given function info in new space 2648 // Create a new closure from the given function info in new space
2646 Node* function_context = assembler->Allocate(size); 2649 Node* function_context = assembler->Allocate(size);
2647 2650
2648 Isolate* isolate = assembler->isolate(); 2651 Isolate* isolate = assembler->isolate();
2649 assembler->StoreMapNoWriteBarrier( 2652 assembler->StoreMapNoWriteBarrier(function_context,
2650 function_context, 2653 assembler->HeapConstant(map));
2651 assembler->HeapConstant(isolate->factory()->function_context_map()));
2652 assembler->StoreObjectFieldNoWriteBarrier(function_context, 2654 assembler->StoreObjectFieldNoWriteBarrier(function_context,
2653 Context::kLengthOffset, 2655 Context::kLengthOffset,
2654 assembler->SmiFromWord32(length)); 2656 assembler->SmiFromWord32(length));
2655 2657
2656 // Set up the fixed slots. 2658 // Set up the fixed slots.
2657 assembler->StoreFixedArrayElement( 2659 assembler->StoreFixedArrayElement(
2658 function_context, assembler->Int32Constant(Context::CLOSURE_INDEX), 2660 function_context, assembler->Int32Constant(Context::CLOSURE_INDEX),
2659 function, SKIP_WRITE_BARRIER); 2661 function, SKIP_WRITE_BARRIER);
2660 assembler->StoreFixedArrayElement( 2662 assembler->StoreFixedArrayElement(
2661 function_context, assembler->Int32Constant(Context::PREVIOUS_INDEX), 2663 function_context, assembler->Int32Constant(Context::PREVIOUS_INDEX),
(...skipping 13 matching lines...) Expand all
2675 assembler->BuildFastFixedArrayForEach( 2677 assembler->BuildFastFixedArrayForEach(
2676 function_context, FAST_ELEMENTS, min_context_slots, length, 2678 function_context, FAST_ELEMENTS, min_context_slots, length,
2677 [undefined](CodeStubAssembler* assembler, Node* context, Node* offset) { 2679 [undefined](CodeStubAssembler* assembler, Node* context, Node* offset) {
2678 assembler->StoreNoWriteBarrier(MachineType::PointerRepresentation(), 2680 assembler->StoreNoWriteBarrier(MachineType::PointerRepresentation(),
2679 context, offset, undefined); 2681 context, offset, undefined);
2680 }); 2682 });
2681 2683
2682 return function_context; 2684 return function_context;
2683 } 2685 }
2684 2686
2687 } // namespace
2688
2689 // static
2690 compiler::Node* FastNewFunctionContextStub::Generate(
2691 CodeStubAssembler* assembler, compiler::Node* function,
2692 compiler::Node* slots, compiler::Node* context) {
2693 Handle<Map> map = assembler->isolate()->factory()->function_context_map();
2694 return GenerateFastNewFunctionContextStub(assembler, function, slots, context,
2695 map);
2696 }
2697
2685 void FastNewFunctionContextStub::GenerateAssembly( 2698 void FastNewFunctionContextStub::GenerateAssembly(
2686 CodeStubAssembler* assembler) const { 2699 CodeStubAssembler* assembler) const {
2687 typedef compiler::Node Node; 2700 typedef compiler::Node Node;
2688 Node* function = assembler->Parameter(Descriptor::kFunction); 2701 Node* function = assembler->Parameter(Descriptor::kFunction);
2689 Node* slots = assembler->Parameter(FastNewFunctionContextDescriptor::kSlots); 2702 Node* slots = assembler->Parameter(FastNewFunctionContextDescriptor::kSlots);
2690 Node* context = assembler->Parameter(Descriptor::kContext); 2703 Node* context = assembler->Parameter(Descriptor::kContext);
2691 2704
2692 assembler->Return(Generate(assembler, function, slots, context)); 2705 assembler->Return(Generate(assembler, function, slots, context));
2693 } 2706 }
2694 2707
2695 // static 2708 // static
2709 compiler::Node* FastNewEvalContextStub::Generate(CodeStubAssembler* assembler,
2710 compiler::Node* function,
2711 compiler::Node* slots,
2712 compiler::Node* context) {
2713 Handle<Map> map = assembler->isolate()->factory()->eval_context_map();
2714 return GenerateFastNewFunctionContextStub(assembler, function, slots, context,
2715 map);
2716 }
2717
2718 void FastNewEvalContextStub::GenerateAssembly(
2719 CodeStubAssembler* assembler) const {
2720 typedef compiler::Node Node;
2721 Node* function = assembler->Parameter(Descriptor::kFunction);
2722 Node* slots = assembler->Parameter(FastNewFunctionContextDescriptor::kSlots);
2723 Node* context = assembler->Parameter(Descriptor::kContext);
2724
2725 assembler->Return(Generate(assembler, function, slots, context));
2726 }
2727
2728 // static
2696 compiler::Node* FastCloneRegExpStub::Generate(CodeStubAssembler* assembler, 2729 compiler::Node* FastCloneRegExpStub::Generate(CodeStubAssembler* assembler,
2697 compiler::Node* closure, 2730 compiler::Node* closure,
2698 compiler::Node* literal_index, 2731 compiler::Node* literal_index,
2699 compiler::Node* pattern, 2732 compiler::Node* pattern,
2700 compiler::Node* flags, 2733 compiler::Node* flags,
2701 compiler::Node* context) { 2734 compiler::Node* context) {
2702 typedef CodeStubAssembler::Label Label; 2735 typedef CodeStubAssembler::Label Label;
2703 typedef CodeStubAssembler::Variable Variable; 2736 typedef CodeStubAssembler::Variable Variable;
2704 typedef compiler::Node Node; 2737 typedef compiler::Node Node;
2705 2738
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
3233 } 3266 }
3234 3267
3235 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) 3268 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate)
3236 : PlatformCodeStub(isolate) {} 3269 : PlatformCodeStub(isolate) {}
3237 3270
3238 InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate) 3271 InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate)
3239 : PlatformCodeStub(isolate) {} 3272 : PlatformCodeStub(isolate) {}
3240 3273
3241 } // namespace internal 3274 } // namespace internal
3242 } // namespace v8 3275 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698