OLD | NEW |
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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 610 |
611 void StringLengthStub::GenerateAssembly( | 611 void StringLengthStub::GenerateAssembly( |
612 compiler::CodeAssemblerState* state) const { | 612 compiler::CodeAssemblerState* state) const { |
613 CodeStubAssembler assembler(state); | 613 CodeStubAssembler assembler(state); |
614 compiler::Node* value = assembler.Parameter(0); | 614 compiler::Node* value = assembler.Parameter(0); |
615 compiler::Node* string = assembler.LoadJSValueValue(value); | 615 compiler::Node* string = assembler.LoadJSValueValue(value); |
616 compiler::Node* result = assembler.LoadStringLength(string); | 616 compiler::Node* result = assembler.LoadStringLength(string); |
617 assembler.Return(result); | 617 assembler.Return(result); |
618 } | 618 } |
619 | 619 |
620 #define BINARY_OP_STUB(Name) \ | 620 #define BINARY_OP_STUB(Name) \ |
621 void Name::GenerateAssembly(compiler::CodeAssemblerState* state) const { \ | 621 void Name::GenerateAssembly(compiler::CodeAssemblerState* state) const { \ |
622 typedef BinaryOpWithVectorDescriptor Descriptor; \ | 622 typedef BinaryOpWithVectorDescriptor Descriptor; \ |
623 CodeStubAssembler assembler(state); \ | 623 CodeStubAssembler assembler(state); \ |
624 assembler.Return(Generate(&assembler, \ | 624 assembler.Return(Generate( \ |
625 assembler.Parameter(Descriptor::kLeft), \ | 625 &assembler, assembler.Parameter(Descriptor::kLeft), \ |
626 assembler.Parameter(Descriptor::kRight), \ | 626 assembler.Parameter(Descriptor::kRight), \ |
627 assembler.Parameter(Descriptor::kSlot), \ | 627 assembler.ChangeUint32ToWord(assembler.Parameter(Descriptor::kSlot)), \ |
628 assembler.Parameter(Descriptor::kVector), \ | 628 assembler.Parameter(Descriptor::kVector), \ |
629 assembler.Parameter(Descriptor::kContext))); \ | 629 assembler.Parameter(Descriptor::kContext))); \ |
630 } | 630 } |
631 BINARY_OP_STUB(AddWithFeedbackStub) | 631 BINARY_OP_STUB(AddWithFeedbackStub) |
632 BINARY_OP_STUB(SubtractWithFeedbackStub) | 632 BINARY_OP_STUB(SubtractWithFeedbackStub) |
633 BINARY_OP_STUB(MultiplyWithFeedbackStub) | 633 BINARY_OP_STUB(MultiplyWithFeedbackStub) |
634 BINARY_OP_STUB(DivideWithFeedbackStub) | 634 BINARY_OP_STUB(DivideWithFeedbackStub) |
635 BINARY_OP_STUB(ModulusWithFeedbackStub) | 635 BINARY_OP_STUB(ModulusWithFeedbackStub) |
636 #undef BINARY_OP_STUB | 636 #undef BINARY_OP_STUB |
637 | 637 |
638 // static | 638 // static |
639 compiler::Node* AddWithFeedbackStub::Generate( | 639 compiler::Node* AddWithFeedbackStub::Generate( |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 Label divisor_is_smi(assembler), divisor_is_not_smi(assembler); | 1225 Label divisor_is_smi(assembler), divisor_is_not_smi(assembler); |
1226 assembler->Branch(assembler->TaggedIsSmi(divisor), &divisor_is_smi, | 1226 assembler->Branch(assembler->TaggedIsSmi(divisor), &divisor_is_smi, |
1227 &divisor_is_not_smi); | 1227 &divisor_is_not_smi); |
1228 | 1228 |
1229 assembler->Bind(&divisor_is_smi); | 1229 assembler->Bind(&divisor_is_smi); |
1230 { | 1230 { |
1231 Label bailout(assembler); | 1231 Label bailout(assembler); |
1232 | 1232 |
1233 // Do floating point division if {divisor} is zero. | 1233 // Do floating point division if {divisor} is zero. |
1234 assembler->GotoIf( | 1234 assembler->GotoIf( |
1235 assembler->WordEqual(divisor, assembler->IntPtrConstant(0)), | 1235 assembler->WordEqual(divisor, assembler->SmiConstant(0)), &bailout); |
1236 &bailout); | |
1237 | 1236 |
1238 // Do floating point division {dividend} is zero and {divisor} is | 1237 // Do floating point division {dividend} is zero and {divisor} is |
1239 // negative. | 1238 // negative. |
1240 Label dividend_is_zero(assembler), dividend_is_not_zero(assembler); | 1239 Label dividend_is_zero(assembler), dividend_is_not_zero(assembler); |
1241 assembler->Branch( | 1240 assembler->Branch( |
1242 assembler->WordEqual(dividend, assembler->IntPtrConstant(0)), | 1241 assembler->WordEqual(dividend, assembler->SmiConstant(0)), |
1243 ÷nd_is_zero, ÷nd_is_not_zero); | 1242 ÷nd_is_zero, ÷nd_is_not_zero); |
1244 | 1243 |
1245 assembler->Bind(÷nd_is_zero); | 1244 assembler->Bind(÷nd_is_zero); |
1246 { | 1245 { |
1247 assembler->GotoIf( | 1246 assembler->GotoIf( |
1248 assembler->IntPtrLessThan(divisor, assembler->IntPtrConstant(0)), | 1247 assembler->SmiLessThan(divisor, assembler->SmiConstant(0)), |
1249 &bailout); | 1248 &bailout); |
1250 assembler->Goto(÷nd_is_not_zero); | 1249 assembler->Goto(÷nd_is_not_zero); |
1251 } | 1250 } |
1252 assembler->Bind(÷nd_is_not_zero); | 1251 assembler->Bind(÷nd_is_not_zero); |
1253 | 1252 |
1254 Node* untagged_divisor = assembler->SmiUntag(divisor); | 1253 Node* untagged_divisor = assembler->SmiToWord32(divisor); |
1255 Node* untagged_dividend = assembler->SmiUntag(dividend); | 1254 Node* untagged_dividend = assembler->SmiToWord32(dividend); |
1256 | 1255 |
1257 // Do floating point division if {dividend} is kMinInt (or kMinInt - 1 | 1256 // Do floating point division if {dividend} is kMinInt (or kMinInt - 1 |
1258 // if the Smi size is 31) and {divisor} is -1. | 1257 // if the Smi size is 31) and {divisor} is -1. |
1259 Label divisor_is_minus_one(assembler), | 1258 Label divisor_is_minus_one(assembler), |
1260 divisor_is_not_minus_one(assembler); | 1259 divisor_is_not_minus_one(assembler); |
1261 assembler->Branch(assembler->Word32Equal(untagged_divisor, | 1260 assembler->Branch(assembler->Word32Equal(untagged_divisor, |
1262 assembler->Int32Constant(-1)), | 1261 assembler->Int32Constant(-1)), |
1263 &divisor_is_minus_one, &divisor_is_not_minus_one); | 1262 &divisor_is_minus_one, &divisor_is_not_minus_one); |
1264 | 1263 |
1265 assembler->Bind(&divisor_is_minus_one); | 1264 assembler->Bind(&divisor_is_minus_one); |
1266 { | 1265 { |
1267 assembler->GotoIf( | 1266 assembler->GotoIf( |
1268 assembler->Word32Equal( | 1267 assembler->Word32Equal( |
1269 untagged_dividend, | 1268 untagged_dividend, |
1270 assembler->Int32Constant(kSmiValueSize == 32 ? kMinInt | 1269 assembler->Int32Constant(kSmiValueSize == 32 ? kMinInt |
1271 : (kMinInt >> 1))), | 1270 : (kMinInt >> 1))), |
1272 &bailout); | 1271 &bailout); |
1273 assembler->Goto(&divisor_is_not_minus_one); | 1272 assembler->Goto(&divisor_is_not_minus_one); |
1274 } | 1273 } |
1275 assembler->Bind(&divisor_is_not_minus_one); | 1274 assembler->Bind(&divisor_is_not_minus_one); |
1276 | 1275 |
1277 Node* untagged_result = | 1276 Node* untagged_result = |
1278 assembler->Int32Div(untagged_dividend, untagged_divisor); | 1277 assembler->Int32Div(untagged_dividend, untagged_divisor); |
1279 Node* truncated = assembler->Int32Mul(untagged_result, untagged_divisor); | 1278 Node* truncated = assembler->Int32Mul(untagged_result, untagged_divisor); |
1280 // Do floating point division if the remainder is not 0. | 1279 // Do floating point division if the remainder is not 0. |
1281 assembler->GotoIf(assembler->Word32NotEqual(untagged_dividend, truncated), | 1280 assembler->GotoIf(assembler->Word32NotEqual(untagged_dividend, truncated), |
1282 &bailout); | 1281 &bailout); |
1283 var_type_feedback.Bind( | 1282 var_type_feedback.Bind( |
1284 assembler->Int32Constant(BinaryOperationFeedback::kSignedSmall)); | 1283 assembler->Int32Constant(BinaryOperationFeedback::kSignedSmall)); |
1285 var_result.Bind(assembler->SmiTag(untagged_result)); | 1284 var_result.Bind(assembler->SmiFromWord32(untagged_result)); |
1286 assembler->Goto(&end); | 1285 assembler->Goto(&end); |
1287 | 1286 |
1288 // Bailout: convert {dividend} and {divisor} to double and do double | 1287 // Bailout: convert {dividend} and {divisor} to double and do double |
1289 // division. | 1288 // division. |
1290 assembler->Bind(&bailout); | 1289 assembler->Bind(&bailout); |
1291 { | 1290 { |
1292 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); | 1291 var_dividend_float64.Bind(assembler->SmiToFloat64(dividend)); |
1293 var_divisor_float64.Bind(assembler->SmiToFloat64(divisor)); | 1292 var_divisor_float64.Bind(assembler->SmiToFloat64(divisor)); |
1294 assembler->Goto(&do_fdiv); | 1293 assembler->Goto(&do_fdiv); |
1295 } | 1294 } |
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 typedef CodeStubAssembler::Label Label; | 2136 typedef CodeStubAssembler::Label Label; |
2138 CodeStubAssembler assembler(state); | 2137 CodeStubAssembler assembler(state); |
2139 | 2138 |
2140 Node* receiver = assembler.Parameter(Descriptor::kReceiver); | 2139 Node* receiver = assembler.Parameter(Descriptor::kReceiver); |
2141 Node* key = assembler.Parameter(Descriptor::kName); | 2140 Node* key = assembler.Parameter(Descriptor::kName); |
2142 Node* slot = assembler.Parameter(Descriptor::kSlot); | 2141 Node* slot = assembler.Parameter(Descriptor::kSlot); |
2143 Node* vector = assembler.Parameter(Descriptor::kVector); | 2142 Node* vector = assembler.Parameter(Descriptor::kVector); |
2144 Node* context = assembler.Parameter(Descriptor::kContext); | 2143 Node* context = assembler.Parameter(Descriptor::kContext); |
2145 | 2144 |
2146 Label if_keyispositivesmi(&assembler), if_keyisinvalid(&assembler); | 2145 Label if_keyispositivesmi(&assembler), if_keyisinvalid(&assembler); |
2147 assembler.Branch(assembler.WordIsPositiveSmi(key), &if_keyispositivesmi, | 2146 assembler.Branch(assembler.TaggedIsPositiveSmi(key), &if_keyispositivesmi, |
2148 &if_keyisinvalid); | 2147 &if_keyisinvalid); |
2149 assembler.Bind(&if_keyispositivesmi); | 2148 assembler.Bind(&if_keyispositivesmi); |
2150 assembler.TailCallRuntime(Runtime::kLoadElementWithInterceptor, context, | 2149 assembler.TailCallRuntime(Runtime::kLoadElementWithInterceptor, context, |
2151 receiver, key); | 2150 receiver, key); |
2152 | 2151 |
2153 assembler.Bind(&if_keyisinvalid); | 2152 assembler.Bind(&if_keyisinvalid); |
2154 assembler.TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, key, | 2153 assembler.TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, key, |
2155 slot, vector); | 2154 slot, vector); |
2156 } | 2155 } |
2157 | 2156 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2199 Node* allocation_size = object_size; | 2198 Node* allocation_size = object_size; |
2200 if (FLAG_allocation_site_pretenuring) { | 2199 if (FLAG_allocation_site_pretenuring) { |
2201 allocation_size = assembler->IntPtrAdd( | 2200 allocation_size = assembler->IntPtrAdd( |
2202 object_size, assembler->IntPtrConstant(AllocationMemento::kSize)); | 2201 object_size, assembler->IntPtrConstant(AllocationMemento::kSize)); |
2203 } | 2202 } |
2204 Node* boilerplate = assembler->LoadObjectField( | 2203 Node* boilerplate = assembler->LoadObjectField( |
2205 allocation_site, AllocationSite::kTransitionInfoOffset); | 2204 allocation_site, AllocationSite::kTransitionInfoOffset); |
2206 Node* boilerplate_map = assembler->LoadMap(boilerplate); | 2205 Node* boilerplate_map = assembler->LoadMap(boilerplate); |
2207 Node* instance_size = assembler->LoadMapInstanceSize(boilerplate_map); | 2206 Node* instance_size = assembler->LoadMapInstanceSize(boilerplate_map); |
2208 Node* size_in_words = assembler->WordShr(object_size, kPointerSizeLog2); | 2207 Node* size_in_words = assembler->WordShr(object_size, kPointerSizeLog2); |
2209 assembler->GotoUnless(assembler->Word32Equal(instance_size, size_in_words), | 2208 assembler->GotoUnless(assembler->WordEqual(instance_size, size_in_words), |
2210 call_runtime); | 2209 call_runtime); |
2211 | 2210 |
2212 Node* copy = assembler->Allocate(allocation_size); | 2211 Node* copy = assembler->Allocate(allocation_size); |
2213 | 2212 |
2214 // Copy boilerplate elements. | 2213 // Copy boilerplate elements. |
2215 Variable offset(assembler, MachineType::PointerRepresentation()); | 2214 Variable offset(assembler, MachineType::PointerRepresentation()); |
2216 offset.Bind(assembler->IntPtrConstant(-kHeapObjectTag)); | 2215 offset.Bind(assembler->IntPtrConstant(-kHeapObjectTag)); |
2217 Node* end_offset = assembler->IntPtrAdd(object_size, offset.value()); | 2216 Node* end_offset = assembler->IntPtrAdd(object_size, offset.value()); |
2218 Label loop_body(assembler, &offset), loop_check(assembler, &offset); | 2217 Label loop_body(assembler, &offset), loop_check(assembler, &offset); |
2219 // We should always have an object size greater than zero. | 2218 // We should always have an object size greater than zero. |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2575 result, JSFunction::kPrototypeOrInitialMapOffset, | 2574 result, JSFunction::kPrototypeOrInitialMapOffset, |
2576 assembler->TheHoleConstant()); | 2575 assembler->TheHoleConstant()); |
2577 assembler->StoreObjectFieldNoWriteBarrier( | 2576 assembler->StoreObjectFieldNoWriteBarrier( |
2578 result, JSFunction::kSharedFunctionInfoOffset, shared_info); | 2577 result, JSFunction::kSharedFunctionInfoOffset, shared_info); |
2579 assembler->StoreObjectFieldNoWriteBarrier(result, JSFunction::kContextOffset, | 2578 assembler->StoreObjectFieldNoWriteBarrier(result, JSFunction::kContextOffset, |
2580 context); | 2579 context); |
2581 Handle<Code> lazy_builtin_handle( | 2580 Handle<Code> lazy_builtin_handle( |
2582 assembler->isolate()->builtins()->builtin(Builtins::kCompileLazy)); | 2581 assembler->isolate()->builtins()->builtin(Builtins::kCompileLazy)); |
2583 Node* lazy_builtin = assembler->HeapConstant(lazy_builtin_handle); | 2582 Node* lazy_builtin = assembler->HeapConstant(lazy_builtin_handle); |
2584 Node* lazy_builtin_entry = assembler->IntPtrAdd( | 2583 Node* lazy_builtin_entry = assembler->IntPtrAdd( |
2585 lazy_builtin, | 2584 assembler->BitcastTaggedToWord(lazy_builtin), |
2586 assembler->IntPtrConstant(Code::kHeaderSize - kHeapObjectTag)); | 2585 assembler->IntPtrConstant(Code::kHeaderSize - kHeapObjectTag)); |
2587 assembler->StoreObjectFieldNoWriteBarrier( | 2586 assembler->StoreObjectFieldNoWriteBarrier( |
2588 result, JSFunction::kCodeEntryOffset, lazy_builtin_entry); | 2587 result, JSFunction::kCodeEntryOffset, lazy_builtin_entry, |
| 2588 MachineType::PointerRepresentation()); |
2589 assembler->StoreObjectFieldNoWriteBarrier(result, | 2589 assembler->StoreObjectFieldNoWriteBarrier(result, |
2590 JSFunction::kNextFunctionLinkOffset, | 2590 JSFunction::kNextFunctionLinkOffset, |
2591 assembler->UndefinedConstant()); | 2591 assembler->UndefinedConstant()); |
2592 | 2592 |
2593 return result; | 2593 return result; |
2594 } | 2594 } |
2595 | 2595 |
2596 void FastNewClosureStub::GenerateAssembly( | 2596 void FastNewClosureStub::GenerateAssembly( |
2597 compiler::CodeAssemblerState* state) const { | 2597 compiler::CodeAssemblerState* state) const { |
| 2598 typedef compiler::Node Node; |
2598 CodeStubAssembler assembler(state); | 2599 CodeStubAssembler assembler(state); |
2599 assembler.Return( | 2600 Node* shared = assembler.Parameter(Descriptor::kSharedFunctionInfo); |
2600 Generate(&assembler, assembler.Parameter(0), assembler.Parameter(1))); | 2601 Node* context = assembler.Parameter(Descriptor::kContext); |
| 2602 assembler.Return(Generate(&assembler, shared, context)); |
2601 } | 2603 } |
2602 | 2604 |
2603 // static | 2605 // static |
2604 compiler::Node* FastNewFunctionContextStub::Generate( | 2606 compiler::Node* FastNewFunctionContextStub::Generate( |
2605 CodeStubAssembler* assembler, compiler::Node* function, | 2607 CodeStubAssembler* assembler, compiler::Node* function, |
2606 compiler::Node* slots, compiler::Node* context) { | 2608 compiler::Node* slots, compiler::Node* context) { |
2607 typedef compiler::Node Node; | 2609 typedef compiler::Node Node; |
2608 | 2610 |
| 2611 slots = assembler->ChangeUint32ToWord(slots); |
| 2612 |
| 2613 // TODO(ishell): Use CSA::OptimalParameterMode() here. |
| 2614 CodeStubAssembler::ParameterMode mode = CodeStubAssembler::INTPTR_PARAMETERS; |
2609 Node* min_context_slots = | 2615 Node* min_context_slots = |
2610 assembler->Int32Constant(Context::MIN_CONTEXT_SLOTS); | 2616 assembler->IntPtrConstant(Context::MIN_CONTEXT_SLOTS); |
2611 Node* length = assembler->Int32Add(slots, min_context_slots); | 2617 Node* length = assembler->IntPtrAdd(slots, min_context_slots); |
2612 Node* size = assembler->Int32Add( | 2618 Node* size = |
2613 assembler->Word32Shl(length, assembler->Int32Constant(kPointerSizeLog2)), | 2619 assembler->GetFixedArrayAllocationSize(length, FAST_ELEMENTS, mode); |
2614 assembler->Int32Constant(FixedArray::kHeaderSize)); | |
2615 | 2620 |
2616 // Create a new closure from the given function info in new space | 2621 // Create a new closure from the given function info in new space |
2617 Node* function_context = assembler->Allocate(size); | 2622 Node* function_context = assembler->Allocate(size); |
2618 | 2623 |
2619 assembler->StoreMapNoWriteBarrier(function_context, | 2624 assembler->StoreMapNoWriteBarrier(function_context, |
2620 Heap::kFunctionContextMapRootIndex); | 2625 Heap::kFunctionContextMapRootIndex); |
2621 assembler->StoreObjectFieldNoWriteBarrier(function_context, | 2626 assembler->StoreObjectFieldNoWriteBarrier( |
2622 Context::kLengthOffset, | 2627 function_context, Context::kLengthOffset, assembler->SmiTag(length)); |
2623 assembler->SmiFromWord32(length)); | |
2624 | 2628 |
2625 // Set up the fixed slots. | 2629 // Set up the fixed slots. |
2626 assembler->StoreFixedArrayElement(function_context, Context::CLOSURE_INDEX, | 2630 assembler->StoreFixedArrayElement(function_context, Context::CLOSURE_INDEX, |
2627 function, SKIP_WRITE_BARRIER); | 2631 function, SKIP_WRITE_BARRIER); |
2628 assembler->StoreFixedArrayElement(function_context, Context::PREVIOUS_INDEX, | 2632 assembler->StoreFixedArrayElement(function_context, Context::PREVIOUS_INDEX, |
2629 context, SKIP_WRITE_BARRIER); | 2633 context, SKIP_WRITE_BARRIER); |
2630 assembler->StoreFixedArrayElement(function_context, Context::EXTENSION_INDEX, | 2634 assembler->StoreFixedArrayElement(function_context, Context::EXTENSION_INDEX, |
2631 assembler->TheHoleConstant(), | 2635 assembler->TheHoleConstant(), |
2632 SKIP_WRITE_BARRIER); | 2636 SKIP_WRITE_BARRIER); |
2633 | 2637 |
2634 // Copy the native context from the previous context. | 2638 // Copy the native context from the previous context. |
2635 Node* native_context = assembler->LoadNativeContext(context); | 2639 Node* native_context = assembler->LoadNativeContext(context); |
2636 assembler->StoreFixedArrayElement(function_context, | 2640 assembler->StoreFixedArrayElement(function_context, |
2637 Context::NATIVE_CONTEXT_INDEX, | 2641 Context::NATIVE_CONTEXT_INDEX, |
2638 native_context, SKIP_WRITE_BARRIER); | 2642 native_context, SKIP_WRITE_BARRIER); |
2639 | 2643 |
2640 // Initialize the rest of the slots to undefined. | 2644 // Initialize the rest of the slots to undefined. |
2641 Node* undefined = assembler->UndefinedConstant(); | 2645 Node* undefined = assembler->UndefinedConstant(); |
2642 assembler->BuildFastFixedArrayForEach( | 2646 assembler->BuildFastFixedArrayForEach( |
2643 function_context, FAST_ELEMENTS, min_context_slots, length, | 2647 function_context, FAST_ELEMENTS, min_context_slots, length, |
2644 [assembler, undefined](Node* context, Node* offset) { | 2648 [assembler, undefined](Node* context, Node* offset) { |
2645 assembler->StoreNoWriteBarrier(MachineType::PointerRepresentation(), | 2649 assembler->StoreNoWriteBarrier(MachineRepresentation::kTagged, context, |
2646 context, offset, undefined); | 2650 offset, undefined); |
2647 }); | 2651 }, |
| 2652 mode); |
2648 | 2653 |
2649 return function_context; | 2654 return function_context; |
2650 } | 2655 } |
2651 | 2656 |
2652 void FastNewFunctionContextStub::GenerateAssembly( | 2657 void FastNewFunctionContextStub::GenerateAssembly( |
2653 compiler::CodeAssemblerState* state) const { | 2658 compiler::CodeAssemblerState* state) const { |
2654 typedef compiler::Node Node; | 2659 typedef compiler::Node Node; |
2655 CodeStubAssembler assembler(state); | 2660 CodeStubAssembler assembler(state); |
2656 Node* function = assembler.Parameter(Descriptor::kFunction); | 2661 Node* function = assembler.Parameter(Descriptor::kFunction); |
2657 Node* slots = assembler.Parameter(FastNewFunctionContextDescriptor::kSlots); | 2662 Node* slots = assembler.Parameter(Descriptor::kSlots); |
2658 Node* context = assembler.Parameter(Descriptor::kContext); | 2663 Node* context = assembler.Parameter(Descriptor::kContext); |
2659 | 2664 |
2660 assembler.Return(Generate(&assembler, function, slots, context)); | 2665 assembler.Return(Generate(&assembler, function, slots, context)); |
2661 } | 2666 } |
2662 | 2667 |
2663 // static | 2668 // static |
2664 compiler::Node* FastCloneRegExpStub::Generate(CodeStubAssembler* assembler, | 2669 compiler::Node* FastCloneRegExpStub::Generate(CodeStubAssembler* assembler, |
2665 compiler::Node* closure, | 2670 compiler::Node* closure, |
2666 compiler::Node* literal_index, | 2671 compiler::Node* literal_index, |
2667 compiler::Node* pattern, | 2672 compiler::Node* pattern, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2724 compiler::Node* NonEmptyShallowClone(CodeStubAssembler* assembler, | 2729 compiler::Node* NonEmptyShallowClone(CodeStubAssembler* assembler, |
2725 compiler::Node* boilerplate, | 2730 compiler::Node* boilerplate, |
2726 compiler::Node* boilerplate_map, | 2731 compiler::Node* boilerplate_map, |
2727 compiler::Node* boilerplate_elements, | 2732 compiler::Node* boilerplate_elements, |
2728 compiler::Node* allocation_site, | 2733 compiler::Node* allocation_site, |
2729 compiler::Node* capacity, | 2734 compiler::Node* capacity, |
2730 ElementsKind kind) { | 2735 ElementsKind kind) { |
2731 typedef compiler::Node Node; | 2736 typedef compiler::Node Node; |
2732 typedef CodeStubAssembler::ParameterMode ParameterMode; | 2737 typedef CodeStubAssembler::ParameterMode ParameterMode; |
2733 | 2738 |
2734 ParameterMode param_mode = CodeStubAssembler::SMI_PARAMETERS; | 2739 ParameterMode param_mode = assembler->OptimalParameterMode(); |
2735 | 2740 |
2736 Node* length = assembler->LoadJSArrayLength(boilerplate); | 2741 Node* length = assembler->LoadJSArrayLength(boilerplate); |
2737 | 2742 capacity = assembler->UntagParameter(capacity, param_mode); |
2738 if (assembler->Is64()) { | |
2739 capacity = assembler->SmiUntag(capacity); | |
2740 param_mode = CodeStubAssembler::INTEGER_PARAMETERS; | |
2741 } | |
2742 | 2743 |
2743 Node *array, *elements; | 2744 Node *array, *elements; |
2744 std::tie(array, elements) = | 2745 std::tie(array, elements) = |
2745 assembler->AllocateUninitializedJSArrayWithElements( | 2746 assembler->AllocateUninitializedJSArrayWithElements( |
2746 kind, boilerplate_map, length, allocation_site, capacity, param_mode); | 2747 kind, boilerplate_map, length, allocation_site, capacity, param_mode); |
2747 | 2748 |
2748 assembler->Comment("copy elements header"); | 2749 assembler->Comment("copy elements header"); |
2749 // Header consists of map and length. | 2750 // Header consists of map and length. |
2750 STATIC_ASSERT(FixedArrayBase::kHeaderSize == 2 * kPointerSize); | 2751 STATIC_ASSERT(FixedArrayBase::kHeaderSize == 2 * kPointerSize); |
2751 assembler->StoreMap(elements, assembler->LoadMap(boilerplate_elements)); | 2752 assembler->StoreMap(elements, assembler->LoadMap(boilerplate_elements)); |
2752 { | 2753 { |
2753 int offset = FixedArrayBase::kLengthOffset; | 2754 int offset = FixedArrayBase::kLengthOffset; |
2754 assembler->StoreObjectFieldNoWriteBarrier( | 2755 assembler->StoreObjectFieldNoWriteBarrier( |
2755 elements, offset, | 2756 elements, offset, |
2756 assembler->LoadObjectField(boilerplate_elements, offset)); | 2757 assembler->LoadObjectField(boilerplate_elements, offset)); |
2757 } | 2758 } |
2758 | 2759 |
2759 if (assembler->Is64()) { | 2760 length = assembler->UntagParameter(length, param_mode); |
2760 length = assembler->SmiUntag(length); | |
2761 } | |
2762 | 2761 |
2763 assembler->Comment("copy boilerplate elements"); | 2762 assembler->Comment("copy boilerplate elements"); |
2764 assembler->CopyFixedArrayElements(kind, boilerplate_elements, elements, | 2763 assembler->CopyFixedArrayElements(kind, boilerplate_elements, elements, |
2765 length, SKIP_WRITE_BARRIER, param_mode); | 2764 length, SKIP_WRITE_BARRIER, param_mode); |
2766 assembler->IncrementCounter( | 2765 assembler->IncrementCounter( |
2767 assembler->isolate()->counters()->inlined_copied_elements(), 1); | 2766 assembler->isolate()->counters()->inlined_copied_elements(), 1); |
2768 | 2767 |
2769 return array; | 2768 return array; |
2770 } | 2769 } |
2771 | 2770 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3218 } | 3217 } |
3219 | 3218 |
3220 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) | 3219 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) |
3221 : PlatformCodeStub(isolate) {} | 3220 : PlatformCodeStub(isolate) {} |
3222 | 3221 |
3223 InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate) | 3222 InternalArrayConstructorStub::InternalArrayConstructorStub(Isolate* isolate) |
3224 : PlatformCodeStub(isolate) {} | 3223 : PlatformCodeStub(isolate) {} |
3225 | 3224 |
3226 } // namespace internal | 3225 } // namespace internal |
3227 } // namespace v8 | 3226 } // namespace v8 |
OLD | NEW |