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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // o fp: our caller's frame pointer | 131 // o fp: our caller's frame pointer |
132 // o sp: stack pointer | 132 // o sp: stack pointer |
133 // o ra: return address | 133 // o ra: return address |
134 // | 134 // |
135 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 135 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
136 // frames-mips.h for its layout. | 136 // frames-mips.h for its layout. |
137 void FullCodeGenerator::Generate() { | 137 void FullCodeGenerator::Generate() { |
138 CompilationInfo* info = info_; | 138 CompilationInfo* info = info_; |
139 handler_table_ = | 139 handler_table_ = |
140 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); | 140 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); |
| 141 |
| 142 InitializeFeedbackVector(); |
| 143 |
141 profiling_counter_ = isolate()->factory()->NewCell( | 144 profiling_counter_ = isolate()->factory()->NewCell( |
142 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); | 145 Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); |
143 SetFunctionPosition(function()); | 146 SetFunctionPosition(function()); |
144 Comment cmnt(masm_, "[ function compiled by full code generator"); | 147 Comment cmnt(masm_, "[ function compiled by full code generator"); |
145 | 148 |
146 ProfileEntryHookStub::MaybeCallEntryHook(masm_); | 149 ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
147 | 150 |
148 #ifdef DEBUG | 151 #ifdef DEBUG |
149 if (strlen(FLAG_stop_at) > 0 && | 152 if (strlen(FLAG_stop_at) > 0 && |
150 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { | 153 info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 VisitStatements(clause->statements()); | 1083 VisitStatements(clause->statements()); |
1081 } | 1084 } |
1082 | 1085 |
1083 __ bind(nested_statement.break_label()); | 1086 __ bind(nested_statement.break_label()); |
1084 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1087 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1085 } | 1088 } |
1086 | 1089 |
1087 | 1090 |
1088 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { | 1091 void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
1089 Comment cmnt(masm_, "[ ForInStatement"); | 1092 Comment cmnt(masm_, "[ ForInStatement"); |
| 1093 int slot = stmt->ForInFeedbackSlot(); |
1090 SetStatementPosition(stmt); | 1094 SetStatementPosition(stmt); |
1091 | 1095 |
1092 Label loop, exit; | 1096 Label loop, exit; |
1093 ForIn loop_statement(this, stmt); | 1097 ForIn loop_statement(this, stmt); |
1094 increment_loop_depth(); | 1098 increment_loop_depth(); |
1095 | 1099 |
1096 // Get the object to enumerate over. If the object is null or undefined, skip | 1100 // Get the object to enumerate over. If the object is null or undefined, skip |
1097 // over the loop. See ECMA-262 version 5, section 12.6.4. | 1101 // over the loop. See ECMA-262 version 5, section 12.6.4. |
1098 VisitForAccumulatorValue(stmt->enumerable()); | 1102 VisitForAccumulatorValue(stmt->enumerable()); |
1099 __ mov(a0, result_register()); // Result as param to InvokeBuiltin below. | 1103 __ mov(a0, result_register()); // Result as param to InvokeBuiltin below. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 __ jmp(&loop); | 1169 __ jmp(&loop); |
1166 | 1170 |
1167 __ bind(&no_descriptors); | 1171 __ bind(&no_descriptors); |
1168 __ Drop(1); | 1172 __ Drop(1); |
1169 __ jmp(&exit); | 1173 __ jmp(&exit); |
1170 | 1174 |
1171 // We got a fixed array in register v0. Iterate through that. | 1175 // We got a fixed array in register v0. Iterate through that. |
1172 Label non_proxy; | 1176 Label non_proxy; |
1173 __ bind(&fixed_array); | 1177 __ bind(&fixed_array); |
1174 | 1178 |
1175 Handle<Cell> cell = isolate()->factory()->NewCell( | 1179 Handle<Object> feedback = Handle<Object>( |
1176 Handle<Object>(Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker), | 1180 Smi::FromInt(TypeFeedbackInfo::kForInFastCaseMarker), |
1177 isolate())); | 1181 isolate()); |
1178 RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell); | 1182 StoreFeedbackVectorSlot(slot, feedback); |
1179 __ li(a1, cell); | 1183 __ li(a1, FeedbackVector()); |
1180 __ li(a2, Operand(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker))); | 1184 __ li(a2, Operand(Smi::FromInt(TypeFeedbackInfo::kForInSlowCaseMarker))); |
1181 __ sw(a2, FieldMemOperand(a1, Cell::kValueOffset)); | 1185 __ sw(a2, FieldMemOperand(a1, FixedArray::OffsetOfElementAt(slot))); |
1182 | 1186 |
1183 __ li(a1, Operand(Smi::FromInt(1))); // Smi indicates slow check | 1187 __ li(a1, Operand(Smi::FromInt(1))); // Smi indicates slow check |
1184 __ lw(a2, MemOperand(sp, 0 * kPointerSize)); // Get enumerated object | 1188 __ lw(a2, MemOperand(sp, 0 * kPointerSize)); // Get enumerated object |
1185 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); | 1189 STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); |
1186 __ GetObjectType(a2, a3, a3); | 1190 __ GetObjectType(a2, a3, a3); |
1187 __ Branch(&non_proxy, gt, a3, Operand(LAST_JS_PROXY_TYPE)); | 1191 __ Branch(&non_proxy, gt, a3, Operand(LAST_JS_PROXY_TYPE)); |
1188 __ li(a1, Operand(Smi::FromInt(0))); // Zero indicates proxy | 1192 __ li(a1, Operand(Smi::FromInt(0))); // Zero indicates proxy |
1189 __ bind(&non_proxy); | 1193 __ bind(&non_proxy); |
1190 __ Push(a1, v0); // Smi and array | 1194 __ Push(a1, v0); // Smi and array |
1191 __ lw(a1, FieldMemOperand(v0, FixedArray::kLengthOffset)); | 1195 __ lw(a1, FieldMemOperand(v0, FixedArray::kLengthOffset)); |
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2734 int arg_count = args->length(); | 2738 int arg_count = args->length(); |
2735 { PreservePositionScope scope(masm()->positions_recorder()); | 2739 { PreservePositionScope scope(masm()->positions_recorder()); |
2736 for (int i = 0; i < arg_count; i++) { | 2740 for (int i = 0; i < arg_count; i++) { |
2737 VisitForStackValue(args->at(i)); | 2741 VisitForStackValue(args->at(i)); |
2738 } | 2742 } |
2739 } | 2743 } |
2740 // Record source position for debugger. | 2744 // Record source position for debugger. |
2741 SetSourcePosition(expr->position()); | 2745 SetSourcePosition(expr->position()); |
2742 | 2746 |
2743 Handle<Object> uninitialized = | 2747 Handle<Object> uninitialized = |
2744 TypeFeedbackCells::UninitializedSentinel(isolate()); | 2748 TypeFeedbackInfo::UninitializedSentinel(isolate()); |
2745 Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); | 2749 StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized); |
2746 RecordTypeFeedbackCell(expr->CallFeedbackId(), cell); | 2750 __ li(a2, FeedbackVector()); |
2747 __ li(a2, Operand(cell)); | 2751 __ li(a3, Operand(Smi::FromInt(expr->CallFeedbackSlot()))); |
2748 | 2752 |
2749 // Record call targets in unoptimized code. | 2753 // Record call targets in unoptimized code. |
2750 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET); | 2754 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET); |
2751 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | 2755 __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
2752 __ CallStub(&stub, expr->CallFeedbackId()); | 2756 __ CallStub(&stub); |
2753 RecordJSReturnSite(expr); | 2757 RecordJSReturnSite(expr); |
2754 // Restore context register. | 2758 // Restore context register. |
2755 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2759 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
2756 context()->DropAndPlug(1, v0); | 2760 context()->DropAndPlug(1, v0); |
2757 } | 2761 } |
2758 | 2762 |
2759 | 2763 |
2760 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { | 2764 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
2761 // t2: copy of the first argument or undefined if it doesn't exist. | 2765 // t2: copy of the first argument or undefined if it doesn't exist. |
2762 if (arg_count > 0) { | 2766 if (arg_count > 0) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2921 // Call the construct call builtin that handles allocation and | 2925 // Call the construct call builtin that handles allocation and |
2922 // constructor invocation. | 2926 // constructor invocation. |
2923 SetSourcePosition(expr->position()); | 2927 SetSourcePosition(expr->position()); |
2924 | 2928 |
2925 // Load function and argument count into a1 and a0. | 2929 // Load function and argument count into a1 and a0. |
2926 __ li(a0, Operand(arg_count)); | 2930 __ li(a0, Operand(arg_count)); |
2927 __ lw(a1, MemOperand(sp, arg_count * kPointerSize)); | 2931 __ lw(a1, MemOperand(sp, arg_count * kPointerSize)); |
2928 | 2932 |
2929 // Record call targets in unoptimized code. | 2933 // Record call targets in unoptimized code. |
2930 Handle<Object> uninitialized = | 2934 Handle<Object> uninitialized = |
2931 TypeFeedbackCells::UninitializedSentinel(isolate()); | 2935 TypeFeedbackInfo::UninitializedSentinel(isolate()); |
2932 Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); | 2936 StoreFeedbackVectorSlot(expr->CallNewFeedbackSlot(), uninitialized); |
2933 RecordTypeFeedbackCell(expr->CallNewFeedbackId(), cell); | 2937 __ li(a2, FeedbackVector()); |
2934 __ li(a2, Operand(cell)); | 2938 __ li(a3, Operand(Smi::FromInt(expr->CallNewFeedbackSlot()))); |
2935 | 2939 |
2936 CallConstructStub stub(RECORD_CALL_TARGET); | 2940 CallConstructStub stub(RECORD_CALL_TARGET); |
2937 __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); | 2941 __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); |
2938 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); | 2942 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
2939 context()->Plug(v0); | 2943 context()->Plug(v0); |
2940 } | 2944 } |
2941 | 2945 |
2942 | 2946 |
2943 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 2947 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
2944 ZoneList<Expression*>* args = expr->arguments(); | 2948 ZoneList<Expression*>* args = expr->arguments(); |
(...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4970 Assembler::target_address_at(pc_immediate_load_address)) == | 4974 Assembler::target_address_at(pc_immediate_load_address)) == |
4971 reinterpret_cast<uint32_t>( | 4975 reinterpret_cast<uint32_t>( |
4972 isolate->builtins()->OsrAfterStackCheck()->entry())); | 4976 isolate->builtins()->OsrAfterStackCheck()->entry())); |
4973 return OSR_AFTER_STACK_CHECK; | 4977 return OSR_AFTER_STACK_CHECK; |
4974 } | 4978 } |
4975 | 4979 |
4976 | 4980 |
4977 } } // namespace v8::internal | 4981 } } // namespace v8::internal |
4978 | 4982 |
4979 #endif // V8_TARGET_ARCH_MIPS | 4983 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |