| 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 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2604 int arg_count = args->length(); | 2609 int arg_count = args->length(); |
| 2605 { PreservePositionScope scope(masm()->positions_recorder()); | 2610 { PreservePositionScope scope(masm()->positions_recorder()); |
| 2606 for (int i = 0; i < arg_count; i++) { | 2611 for (int i = 0; i < arg_count; i++) { |
| 2607 VisitForStackValue(args->at(i)); | 2612 VisitForStackValue(args->at(i)); |
| 2608 } | 2613 } |
| 2609 } | 2614 } |
| 2610 // Record source position for debugger. | 2615 // Record source position for debugger. |
| 2611 SetSourcePosition(expr->position()); | 2616 SetSourcePosition(expr->position()); |
| 2612 | 2617 |
| 2613 Handle<Object> uninitialized = | 2618 Handle<Object> uninitialized = |
| 2614 TypeFeedbackCells::UninitializedSentinel(isolate()); | 2619 TypeFeedbackInfo::UninitializedSentinel(isolate()); |
| 2615 Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); | 2620 StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized); |
| 2616 RecordTypeFeedbackCell(expr->CallFeedbackId(), cell); | 2621 __ Move(rbx, FeedbackVector()); |
| 2617 __ Move(rbx, cell); | 2622 __ Move(rdx, Smi::FromInt(expr->CallFeedbackSlot())); |
| 2618 | 2623 |
| 2619 // Record call targets in unoptimized code. | 2624 // Record call targets in unoptimized code. |
| 2620 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET); | 2625 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET); |
| 2621 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); | 2626 __ movp(rdi, Operand(rsp, (arg_count + 1) * kPointerSize)); |
| 2622 __ CallStub(&stub, expr->CallFeedbackId()); | 2627 __ CallStub(&stub, expr->CallFeedbackId()); |
| 2623 RecordJSReturnSite(expr); | 2628 RecordJSReturnSite(expr); |
| 2624 // Restore context register. | 2629 // Restore context register. |
| 2625 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2630 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 2626 // Discard the function left on TOS. | 2631 // Discard the function left on TOS. |
| 2627 context()->DropAndPlug(1, rax); | 2632 context()->DropAndPlug(1, rax); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2789 // Call the construct call builtin that handles allocation and | 2794 // Call the construct call builtin that handles allocation and |
| 2790 // constructor invocation. | 2795 // constructor invocation. |
| 2791 SetSourcePosition(expr->position()); | 2796 SetSourcePosition(expr->position()); |
| 2792 | 2797 |
| 2793 // Load function and argument count into rdi and rax. | 2798 // Load function and argument count into rdi and rax. |
| 2794 __ Set(rax, arg_count); | 2799 __ Set(rax, arg_count); |
| 2795 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); | 2800 __ movp(rdi, Operand(rsp, arg_count * kPointerSize)); |
| 2796 | 2801 |
| 2797 // Record call targets in unoptimized code, but not in the snapshot. | 2802 // Record call targets in unoptimized code, but not in the snapshot. |
| 2798 Handle<Object> uninitialized = | 2803 Handle<Object> uninitialized = |
| 2799 TypeFeedbackCells::UninitializedSentinel(isolate()); | 2804 TypeFeedbackInfo::UninitializedSentinel(isolate()); |
| 2800 Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); | 2805 StoreFeedbackVectorSlot(expr->CallNewFeedbackSlot(), uninitialized); |
| 2801 RecordTypeFeedbackCell(expr->CallNewFeedbackId(), cell); | 2806 __ Move(rbx, FeedbackVector()); |
| 2802 __ Move(rbx, cell); | 2807 __ Move(rdx, Smi::FromInt(expr->CallNewFeedbackSlot())); |
| 2803 | 2808 |
| 2804 CallConstructStub stub(RECORD_CALL_TARGET); | 2809 CallConstructStub stub(RECORD_CALL_TARGET); |
| 2805 __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); | 2810 __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); |
| 2806 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2811 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
| 2807 context()->Plug(rax); | 2812 context()->Plug(rax); |
| 2808 } | 2813 } |
| 2809 | 2814 |
| 2810 | 2815 |
| 2811 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 2816 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| 2812 ZoneList<Expression*>* args = expr->arguments(); | 2817 ZoneList<Expression*>* args = expr->arguments(); |
| (...skipping 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4895 | 4900 |
| 4896 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4901 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 4897 Assembler::target_address_at(call_target_address)); | 4902 Assembler::target_address_at(call_target_address)); |
| 4898 return OSR_AFTER_STACK_CHECK; | 4903 return OSR_AFTER_STACK_CHECK; |
| 4899 } | 4904 } |
| 4900 | 4905 |
| 4901 | 4906 |
| 4902 } } // namespace v8::internal | 4907 } } // namespace v8::internal |
| 4903 | 4908 |
| 4904 #endif // V8_TARGET_ARCH_X64 | 4909 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |