OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // o rsi: our context | 111 // o rsi: our context |
112 // o rbp: our caller's frame pointer | 112 // o rbp: our caller's frame pointer |
113 // o rsp: stack pointer (pointing to return address) | 113 // o rsp: stack pointer (pointing to return address) |
114 // | 114 // |
115 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 115 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
116 // frames-x64.h for its layout. | 116 // frames-x64.h for its layout. |
117 void FullCodeGenerator::Generate() { | 117 void FullCodeGenerator::Generate() { |
118 CompilationInfo* info = info_; | 118 CompilationInfo* info = info_; |
119 handler_table_ = | 119 handler_table_ = |
120 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); | 120 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); |
| 121 |
| 122 InitializeFeedbackVector(); |
| 123 |
121 profiling_counter_ = isolate()->factory()->NewCell( | 124 profiling_counter_ = isolate()->factory()->NewCell( |
122 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); | 125 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); |
123 SetFunctionPosition(function()); | 126 SetFunctionPosition(function()); |
124 Comment cmnt(masm_, "[ function compiled by full code generator"); | 127 Comment cmnt(masm_, "[ function compiled by full code generator"); |
125 | 128 |
126 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 129 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
127 | 130 |
128 #ifdef DEBUG | 131 #ifdef DEBUG |
129 if (strlen(FLAG_stop_at) > 0 && | 132 if (strlen(FLAG_stop_at) > 0 && |
130 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 133 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 VisitStatements(clause->statements()); | 1031 VisitStatements(clause->statements()); |
1029 } | 1032 } |
1030 | 1033 |
1031 __ bind(nested_statement.break_label()); | 1034 __ bind(nested_statement.break_label()); |
1032 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1035 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1033 } | 1036 } |
1034 | 1037 |
1035 | 1038 |
1036 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 1039 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
1037 Comment cmnt(masm_, "[ ForInStatement"); | 1040 Comment cmnt(masm_, "[ ForInStatement"); |
| 1041 int slot = stmt->ForInFeedbackSlot(); |
1038 SetStatementPosition(stmt); | 1042 SetStatementPosition(stmt); |
1039 | 1043 |
1040 Label loop, exit; | 1044 Label loop, exit; |
1041 ForIn loop_statement(this, stmt); | 1045 ForIn loop_statement(this, stmt); |
1042 increment_loop_depth(); | 1046 increment_loop_depth(); |
1043 | 1047 |
1044 // Get the object to enumerate over. If the object is null or undefined, skip | 1048 // Get the object to enumerate over. If the object is null or undefined, skip |
1045 // over the loop. See ECMA-262 version 5, section 12.6.4. | 1049 // over the loop. See ECMA-262 version 5, section 12.6.4. |
1046 VisitForAccumulatorValue(stmt->enumerable()); | 1050 VisitForAccumulatorValue(stmt->enumerable()); |
1047 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); | 1051 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 __ jmp(&loop); | 1120 __ jmp(&loop); |
1117 | 1121 |
1118 __ bind(&no_descriptors); | 1122 __ bind(&no_descriptors); |
1119 __ addq(rsp, Immediate(kPointerSize)); | 1123 __ addq(rsp, Immediate(kPointerSize)); |
1120 __ jmp(&exit); | 1124 __ jmp(&exit); |
1121 | 1125 |
1122 // We got a fixed array in register rax. Iterate through that. | 1126 // We got a fixed array in register rax. Iterate through that. |
1123 Label non_proxy; | 1127 Label non_proxy; |
1124 __ bind(&fixed_array); | 1128 __ bind(&fixed_array); |
1125 | 1129 |
1126 Handle<Cell> cell = isolate()->factory()->NewCell( | 1130 Handle<Object> feedback = Handle<Object>( |
1127 Handle<Object>(Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker), | 1131 Smi::FromInt(TypeFeedbackInfo::kForInFastCaseMarker), |
1128 isolate())); | 1132 isolate()); |
1129 RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell); | 1133 StoreFeedbackVectorSlot(slot, feedback); |
1130 __ Move(rbx, cell); | |
1131 __ Move(FieldOperand(rbx, Cell::kValueOffset), | |
1132 Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker)); | |
1133 | 1134 |
| 1135 // No need for a write barrier, we are storing a Smi in the feedback vector. |
| 1136 __ Move(rbx, FeedbackVector()); |
| 1137 __ Move(FieldOperand(rbx, FixedArray::OffsetOfElementAt(slot)), |
| 1138 Smi::FromInt(TypeFeedbackInfo::kForInSlowCaseMarker)); |
1134 __ Move(rbx, Smi::FromInt(1)); // Smi indicates slow check | 1139 __ Move(rbx, Smi::FromInt(1)); // Smi indicates slow check |
1135 __ movp(rcx, Operand(rsp, 0 * kPointerSize)); // Get enumerated object | 1140 __ movp(rcx, Operand(rsp, 0 * kPointerSize)); // Get enumerated object |
1136 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); | 1141 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); |
1137 __ CmpObjectType(rcx, LAST_JS_PROXY_TYPE, rcx); | 1142 __ CmpObjectType(rcx, LAST_JS_PROXY_TYPE, rcx); |
1138 __ j(above, &non_proxy); | 1143 __ j(above, &non_proxy); |
1139 __ Move(rbx, Smi::FromInt(0)); // Zero indicates proxy | 1144 __ Move(rbx, Smi::FromInt(0)); // Zero indicates proxy |
1140 __ bind(&non_proxy); | 1145 __ bind(&non_proxy); |
1141 __ push(rbx); // Smi | 1146 __ push(rbx); // Smi |
1142 __ push(rax); // Array | 1147 __ push(rax); // Array |
1143 __ movp(rax, FieldOperand(rax, FixedArray::kLengthOffset)); | 1148 __ movp(rax, FieldOperand(rax, FixedArray::kLengthOffset)); |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2643 int arg_count = args->length(); | 2648 int arg_count = args->length(); |
2644 { PreservePositionScope scope(masm()->positions_recorder()); | 2649 { PreservePositionScope scope(masm()->positions_recorder()); |
2645 for (int i = 0; i < arg_count; i++) { | 2650 for (int i = 0; i < arg_count; i++) { |
2646 VisitForStackValue(args->at(i)); | 2651 VisitForStackValue(args->at(i)); |
2647 } | 2652 } |
2648 } | 2653 } |
2649 // Record source position for debugger. | 2654 // Record source position for debugger. |
2650 SetSourcePosition(expr->position()); | 2655 SetSourcePosition(expr->position()); |
2651 | 2656 |
2652 Handle<Object> uninitialized = | 2657 Handle<Object> uninitialized = |
2653 TypeFeedbackCells::UninitializedSentinel(isolate()); | 2658 TypeFeedbackInfo::UninitializedSentinel(isolate()); |
2654 Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); | 2659 StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized); |
2655 RecordTypeFeedbackCell(expr->CallFeedbackId(), cell); | 2660 __ Move(rbx, FeedbackVector()); |
2656 __ Move(rbx, cell); | 2661 __ Move(rdx, Smi::FromInt(expr->CallFeedbackSlot())); |
2657 | 2662 |
2658 // Record call targets in unoptimized code. | 2663 // Record call targets in unoptimized code. |
2659 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET); | 2664 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET); |
2660 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 2665 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
2661 __ CallStub(&stub, expr->CallFeedbackId()); | 2666 __ CallStub(&stub); |
2662 RecordJSReturnSite(expr); | 2667 RecordJSReturnSite(expr); |
2663 // Restore context register. | 2668 // Restore context register. |
2664 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2669 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
2665 // Discard the function left on TOS. | 2670 // Discard the function left on TOS. |
2666 context()->DropAndPlug(1, rax); | 2671 context()->DropAndPlug(1, rax); |
2667 } | 2672 } |
2668 | 2673 |
2669 | 2674 |
2670 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { | 2675 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
2671 // Push copy of the first argument or undefined if it doesn't exist. | 2676 // Push copy of the first argument or undefined if it doesn't exist. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2823 // Call the construct call builtin that handles allocation and | 2828 // Call the construct call builtin that handles allocation and |
2824 // constructor invocation. | 2829 // constructor invocation. |
2825 SetSourcePosition(expr->position()); | 2830 SetSourcePosition(expr->position()); |
2826 | 2831 |
2827 // Load function and argument count into rdi and rax. | 2832 // Load function and argument count into rdi and rax. |
2828 __ Set(rax, arg_count); | 2833 __ Set(rax, arg_count); |
2829 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); | 2834 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
2830 | 2835 |
2831 // Record call targets in unoptimized code, but not in the snapshot. | 2836 // Record call targets in unoptimized code, but not in the snapshot. |
2832 Handle<Object> uninitialized = | 2837 Handle<Object> uninitialized = |
2833 TypeFeedbackCells::UninitializedSentinel(isolate()); | 2838 TypeFeedbackInfo::UninitializedSentinel(isolate()); |
2834 Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); | 2839 StoreFeedbackVectorSlot(expr->CallNewFeedbackSlot(), uninitialized); |
2835 RecordTypeFeedbackCell(expr->CallNewFeedbackId(), cell); | 2840 __ Move(rbx, FeedbackVector()); |
2836 __ Move(rbx, cell); | 2841 __ Move(rdx, Smi::FromInt(expr->CallNewFeedbackSlot())); |
2837 | 2842 |
2838 CallConstructStub stub(RECORD_CALL_TARGET); | 2843 CallConstructStub stub(RECORD_CALL_TARGET); |
2839 __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); | 2844 __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); |
2840 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2845 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
2841 context()->Plug(rax); | 2846 context()->Plug(rax); |
2842 } | 2847 } |
2843 | 2848 |
2844 | 2849 |
2845 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 2850 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
2846 ZoneList<Expression*>* args = expr->arguments(); | 2851 ZoneList<Expression*>* args = expr->arguments(); |
(...skipping 2060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4907 | 4912 |
4908 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4913 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4909 Assembler::target_address_at(call_target_address)); | 4914 Assembler::target_address_at(call_target_address)); |
4910 return OSR_AFTER_STACK_CHECK; | 4915 return OSR_AFTER_STACK_CHECK; |
4911 } | 4916 } |
4912 | 4917 |
4913 | 4918 |
4914 } } // namespace v8::internal | 4919 } } // namespace v8::internal |
4915 | 4920 |
4916 #endif // V8_TARGET_ARCH_X64 | 4921 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |