| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 MacroAssembler* masm_; | 104 MacroAssembler* masm_; |
| 105 Label patch_site_; | 105 Label patch_site_; |
| 106 #ifdef DEBUG | 106 #ifdef DEBUG |
| 107 bool info_emitted_; | 107 bool info_emitted_; |
| 108 #endif | 108 #endif |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 | 111 |
| 112 int FullCodeGenerator::self_optimization_header_size() { |
| 113 return 24; |
| 114 } |
| 115 |
| 116 |
| 112 // Generate code for a JS function. On entry to the function the receiver | 117 // Generate code for a JS function. On entry to the function the receiver |
| 113 // and arguments have been pushed on the stack left to right. The actual | 118 // and arguments have been pushed on the stack left to right. The actual |
| 114 // argument count matches the formal parameter count expected by the | 119 // argument count matches the formal parameter count expected by the |
| 115 // function. | 120 // function. |
| 116 // | 121 // |
| 117 // The live registers are: | 122 // The live registers are: |
| 118 // o r1: the JS function object being called (i.e., ourselves) | 123 // o r1: the JS function object being called (i.e., ourselves) |
| 119 // o cp: our context | 124 // o cp: our context |
| 120 // o fp: our caller's frame pointer | 125 // o fp: our caller's frame pointer |
| 121 // o sp: stack pointer | 126 // o sp: stack pointer |
| 122 // o lr: return address | 127 // o lr: return address |
| 123 // | 128 // |
| 124 // The function builds a JS frame. Please see JavaScriptFrameConstants in | 129 // The function builds a JS frame. Please see JavaScriptFrameConstants in |
| 125 // frames-arm.h for its layout. | 130 // frames-arm.h for its layout. |
| 126 void FullCodeGenerator::Generate() { | 131 void FullCodeGenerator::Generate() { |
| 127 CompilationInfo* info = info_; | 132 CompilationInfo* info = info_; |
| 128 handler_table_ = | 133 handler_table_ = |
| 129 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); | 134 isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); |
| 130 SetFunctionPosition(function()); | 135 SetFunctionPosition(function()); |
| 131 Comment cmnt(masm_, "[ function compiled by full code generator"); | 136 Comment cmnt(masm_, "[ function compiled by full code generator"); |
| 132 | 137 |
| 133 #ifdef DEBUG | |
| 134 if (strlen(FLAG_stop_at) > 0 && | |
| 135 info->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) { | |
| 136 __ stop("stop-at"); | |
| 137 } | |
| 138 #endif | |
| 139 | |
| 140 // We can optionally optimize based on counters rather than statistical | 138 // We can optionally optimize based on counters rather than statistical |
| 141 // sampling. | 139 // sampling. |
| 142 if (info->ShouldSelfOptimize()) { | 140 if (info->ShouldSelfOptimize()) { |
| 143 if (FLAG_trace_opt_verbose) { | 141 if (FLAG_trace_opt_verbose) { |
| 144 PrintF("[adding self-optimization header to %s]\n", | 142 PrintF("[adding self-optimization header to %s]\n", |
| 145 *info->function()->debug_name()->ToCString()); | 143 *info->function()->debug_name()->ToCString()); |
| 146 } | 144 } |
| 145 has_self_optimization_header_ = true; |
| 147 MaybeObject* maybe_cell = isolate()->heap()->AllocateJSGlobalPropertyCell( | 146 MaybeObject* maybe_cell = isolate()->heap()->AllocateJSGlobalPropertyCell( |
| 148 Smi::FromInt(Compiler::kCallsUntilPrimitiveOpt)); | 147 Smi::FromInt(Compiler::kCallsUntilPrimitiveOpt)); |
| 149 JSGlobalPropertyCell* cell; | 148 JSGlobalPropertyCell* cell; |
| 150 if (maybe_cell->To(&cell)) { | 149 if (maybe_cell->To(&cell)) { |
| 151 __ mov(r2, Operand(Handle<JSGlobalPropertyCell>(cell))); | 150 __ mov(r2, Operand(Handle<JSGlobalPropertyCell>(cell))); |
| 152 __ ldr(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); | 151 __ ldr(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 153 __ sub(r3, r3, Operand(Smi::FromInt(1)), SetCC); | 152 __ sub(r3, r3, Operand(Smi::FromInt(1)), SetCC); |
| 154 __ str(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); | 153 __ str(r3, FieldMemOperand(r2, JSGlobalPropertyCell::kValueOffset)); |
| 155 Handle<Code> compile_stub( | 154 Handle<Code> compile_stub( |
| 156 isolate()->builtins()->builtin(Builtins::kLazyRecompile)); | 155 isolate()->builtins()->builtin(Builtins::kLazyRecompile)); |
| 157 __ Jump(compile_stub, RelocInfo::CODE_TARGET, eq); | 156 __ Jump(compile_stub, RelocInfo::CODE_TARGET, eq); |
| 157 ASSERT(masm_->pc_offset() == self_optimization_header_size()); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 #ifdef DEBUG |
| 162 if (strlen(FLAG_stop_at) > 0 && |
| 163 info->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) { |
| 164 __ stop("stop-at"); |
| 165 } |
| 166 #endif |
| 167 |
| 161 // Strict mode functions and builtins need to replace the receiver | 168 // Strict mode functions and builtins need to replace the receiver |
| 162 // with undefined when called as functions (without an explicit | 169 // with undefined when called as functions (without an explicit |
| 163 // receiver object). r5 is zero for method calls and non-zero for | 170 // receiver object). r5 is zero for method calls and non-zero for |
| 164 // function calls. | 171 // function calls. |
| 165 if (!info->is_classic_mode() || info->is_native()) { | 172 if (!info->is_classic_mode() || info->is_native()) { |
| 166 Label ok; | 173 Label ok; |
| 167 __ cmp(r5, Operand(0)); | 174 __ cmp(r5, Operand(0)); |
| 168 __ b(eq, &ok); | 175 __ b(eq, &ok); |
| 169 int receiver_offset = info->scope()->num_parameters() * kPointerSize; | 176 int receiver_offset = info->scope()->num_parameters() * kPointerSize; |
| 170 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); | 177 __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
| (...skipping 4212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4383 *context_length = 0; | 4390 *context_length = 0; |
| 4384 return previous_; | 4391 return previous_; |
| 4385 } | 4392 } |
| 4386 | 4393 |
| 4387 | 4394 |
| 4388 #undef __ | 4395 #undef __ |
| 4389 | 4396 |
| 4390 } } // namespace v8::internal | 4397 } } // namespace v8::internal |
| 4391 | 4398 |
| 4392 #endif // V8_TARGET_ARCH_ARM | 4399 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |