yangguo@chromium.org | 78d1ad4 | 2012-02-09 13:53:47 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #include "v8.h" |
| 29 | |
jkummerow@chromium.org | 93a47f4 | 2013-07-02 14:43:41 +0000 | [diff] [blame] | 30 | #if V8_TARGET_ARCH_ARM |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 31 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 32 | #include "code-stubs.h" |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 33 | #include "codegen.h" |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 34 | #include "compiler.h" |
| 35 | #include "debug.h" |
| 36 | #include "full-codegen.h" |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 37 | #include "isolate-inl.h" |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 38 | #include "parser.h" |
sgjesse@chromium.org | 833cdd7 | 2010-02-26 10:06:16 +0000 | [diff] [blame] | 39 | #include "scopes.h" |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 40 | #include "stub-cache.h" |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 41 | |
lrn@chromium.org | 5d00b60 | 2011-01-05 09:51:43 +0000 | [diff] [blame] | 42 | #include "arm/code-stubs-arm.h" |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 43 | #include "arm/macro-assembler-arm.h" |
lrn@chromium.org | 5d00b60 | 2011-01-05 09:51:43 +0000 | [diff] [blame] | 44 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 45 | namespace v8 { |
| 46 | namespace internal { |
| 47 | |
| 48 | #define __ ACCESS_MASM(masm_) |
| 49 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 50 | |
| 51 | // A patch site is a location in the code which it is possible to patch. This |
| 52 | // class has a number of methods to emit the code which is patchable and the |
| 53 | // method EmitPatchInfo to record a marker back to the patchable code. This |
| 54 | // marker is a cmp rx, #yyy instruction, and x * 0x00000fff + yyy (raw 12 bit |
| 55 | // immediate value is used) is the delta from the pc to the first instruction of |
| 56 | // the patchable code. |
| 57 | class JumpPatchSite BASE_EMBEDDED { |
| 58 | public: |
| 59 | explicit JumpPatchSite(MacroAssembler* masm) : masm_(masm) { |
| 60 | #ifdef DEBUG |
| 61 | info_emitted_ = false; |
| 62 | #endif |
| 63 | } |
| 64 | |
| 65 | ~JumpPatchSite() { |
| 66 | ASSERT(patch_site_.is_bound() == info_emitted_); |
| 67 | } |
| 68 | |
| 69 | // When initially emitting this ensure that a jump is always generated to skip |
| 70 | // the inlined smi code. |
| 71 | void EmitJumpIfNotSmi(Register reg, Label* target) { |
| 72 | ASSERT(!patch_site_.is_bound() && !info_emitted_); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 73 | Assembler::BlockConstPoolScope block_const_pool(masm_); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 74 | __ bind(&patch_site_); |
| 75 | __ cmp(reg, Operand(reg)); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 76 | __ b(eq, target); // Always taken before patched. |
| 77 | } |
| 78 | |
| 79 | // When initially emitting this ensure that a jump is never generated to skip |
| 80 | // the inlined smi code. |
| 81 | void EmitJumpIfSmi(Register reg, Label* target) { |
| 82 | ASSERT(!patch_site_.is_bound() && !info_emitted_); |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame] | 83 | Assembler::BlockConstPoolScope block_const_pool(masm_); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 84 | __ bind(&patch_site_); |
| 85 | __ cmp(reg, Operand(reg)); |
| 86 | __ b(ne, target); // Never taken before patched. |
| 87 | } |
| 88 | |
| 89 | void EmitPatchInfo() { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 90 | // Block literal pool emission whilst recording patch site information. |
| 91 | Assembler::BlockConstPoolScope block_const_pool(masm_); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 92 | if (patch_site_.is_bound()) { |
| 93 | int delta_to_patch_site = masm_->InstructionsGeneratedSince(&patch_site_); |
| 94 | Register reg; |
| 95 | reg.set_code(delta_to_patch_site / kOff12Mask); |
| 96 | __ cmp_raw_immediate(reg, delta_to_patch_site % kOff12Mask); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 97 | #ifdef DEBUG |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 98 | info_emitted_ = true; |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 99 | #endif |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 100 | } else { |
| 101 | __ nop(); // Signals no inlined code. |
| 102 | } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 103 | } |
| 104 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 105 | private: |
| 106 | MacroAssembler* masm_; |
| 107 | Label patch_site_; |
| 108 | #ifdef DEBUG |
| 109 | bool info_emitted_; |
| 110 | #endif |
| 111 | }; |
| 112 | |
| 113 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 114 | // Generate code for a JS function. On entry to the function the receiver |
| 115 | // and arguments have been pushed on the stack left to right. The actual |
| 116 | // argument count matches the formal parameter count expected by the |
| 117 | // function. |
| 118 | // |
| 119 | // The live registers are: |
ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 120 | // o r1: the JS function object being called (i.e., ourselves) |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 121 | // o cp: our context |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 122 | // o pp: our caller's constant pool pointer (if FLAG_enable_ool_constant_pool) |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 123 | // o fp: our caller's frame pointer |
| 124 | // o sp: stack pointer |
| 125 | // o lr: return address |
| 126 | // |
| 127 | // The function builds a JS frame. Please see JavaScriptFrameConstants in |
| 128 | // frames-arm.h for its layout. |
yangguo@chromium.org | 5645471 | 2012-02-16 15:33:53 +0000 | [diff] [blame] | 129 | void FullCodeGenerator::Generate() { |
| 130 | CompilationInfo* info = info_; |
jkummerow@chromium.org | 04e4f1e | 2011-11-14 13:36:17 +0000 | [diff] [blame] | 131 | handler_table_ = |
| 132 | isolate()->factory()->NewFixedArray(function()->handler_count(), TENURED); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 133 | profiling_counter_ = isolate()->factory()->NewCell( |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 134 | Handle<Smi>(Smi::FromInt(FLAG_interrupt_budget), isolate())); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 135 | SetFunctionPosition(function()); |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 136 | Comment cmnt(masm_, "[ function compiled by full code generator"); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 137 | |
verwaest@chromium.org | 753aee4 | 2012-07-17 16:15:42 +0000 | [diff] [blame] | 138 | ProfileEntryHookStub::MaybeCallEntryHook(masm_); |
| 139 | |
yangguo@chromium.org | a7d3df9 | 2012-02-27 11:46:55 +0000 | [diff] [blame] | 140 | #ifdef DEBUG |
| 141 | if (strlen(FLAG_stop_at) > 0 && |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 142 | info->function()->name()->IsUtf8EqualTo(CStrVector(FLAG_stop_at))) { |
yangguo@chromium.org | a7d3df9 | 2012-02-27 11:46:55 +0000 | [diff] [blame] | 143 | __ stop("stop-at"); |
| 144 | } |
| 145 | #endif |
| 146 | |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 147 | // Strict mode functions and builtins need to replace the receiver |
| 148 | // with undefined when called as functions (without an explicit |
| 149 | // receiver object). r5 is zero for method calls and non-zero for |
| 150 | // function calls. |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 151 | if (!info->is_classic_mode() || info->is_native()) { |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 152 | __ cmp(r5, Operand::Zero()); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 153 | int receiver_offset = info->scope()->num_parameters() * kPointerSize; |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 154 | __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
jkummerow@chromium.org | ef33a54 | 2013-10-28 18:03:37 +0000 | [diff] [blame] | 155 | __ str(r2, MemOperand(sp, receiver_offset), ne); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 156 | } |
| 157 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 158 | // Open a frame scope to indicate that there is a frame on the stack. The |
| 159 | // MANUAL indicates that the scope shouldn't actually generate code to set up |
| 160 | // the frame (that is done below). |
| 161 | FrameScope frame_scope(masm_, StackFrame::MANUAL); |
| 162 | |
svenpanne@chromium.org | 83130cf | 2012-11-30 10:13:25 +0000 | [diff] [blame] | 163 | info->set_prologue_offset(masm_->pc_offset()); |
bmeurer@chromium.org | c9913f0 | 2013-10-24 06:31:36 +0000 | [diff] [blame] | 164 | __ Prologue(BUILD_FUNCTION_FRAME); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 165 | info->AddNoFrameRange(0, masm_->pc_offset()); |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 166 | __ LoadConstantPoolPointerRegister(); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 167 | |
| 168 | { Comment cmnt(masm_, "[ Allocate locals"); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 169 | int locals_count = info->scope()->num_stack_slots(); |
| 170 | // Generators allocate locals, if any, in context slots. |
| 171 | ASSERT(!info->function()->is_generator() || locals_count == 0); |
jkummerow@chromium.org | 1048047 | 2013-07-17 08:22:15 +0000 | [diff] [blame] | 172 | if (locals_count > 0) { |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 173 | // Emit a loop to initialize stack cells for locals when optimizing for |
| 174 | // size. Otherwise, unroll the loop for maximum performance. |
| 175 | __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); |
| 176 | if (FLAG_optimize_for_size && locals_count > 4) { |
| 177 | Label loop; |
| 178 | __ mov(r2, Operand(locals_count)); |
| 179 | __ bind(&loop); |
| 180 | __ sub(r2, r2, Operand(1), SetCC); |
| 181 | __ push(r9); |
| 182 | __ b(&loop, ne); |
| 183 | } else { |
| 184 | for (int i = 0; i < locals_count; i++) { |
| 185 | __ push(r9); |
| 186 | } |
jkummerow@chromium.org | 1048047 | 2013-07-17 08:22:15 +0000 | [diff] [blame] | 187 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 188 | } |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 189 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 190 | |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 191 | bool function_in_register = true; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 192 | |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 193 | // Possibly allocate a local context. |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 194 | int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 195 | if (heap_slots > 0) { |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 196 | // Argument to NewContext is the function, which is still in r1. |
| 197 | Comment cmnt(masm_, "[ Allocate context"); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 198 | __ push(r1); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 199 | if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { |
| 200 | __ Push(info->scope()->GetScopeInfo()); |
| 201 | __ CallRuntime(Runtime::kNewGlobalContext, 2); |
| 202 | } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 203 | FastNewContextStub stub(heap_slots); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 204 | __ CallStub(&stub); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 205 | } else { |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 206 | __ CallRuntime(Runtime::kNewFunctionContext, 1); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 207 | } |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 208 | function_in_register = false; |
| 209 | // Context is returned in both r0 and cp. It replaces the context |
| 210 | // passed to us. It's saved in the stack and kept live in cp. |
| 211 | __ str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 212 | // Copy any necessary parameters into the context. |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 213 | int num_parameters = info->scope()->num_parameters(); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 214 | for (int i = 0; i < num_parameters; i++) { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 215 | Variable* var = scope()->parameter(i); |
| 216 | if (var->IsContextSlot()) { |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 217 | int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
| 218 | (num_parameters - 1 - i) * kPointerSize; |
| 219 | // Load parameter from stack. |
| 220 | __ ldr(r0, MemOperand(fp, parameter_offset)); |
| 221 | // Store it in the context. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 222 | MemOperand target = ContextOperand(cp, var->index()); |
| 223 | __ str(r0, target); |
| 224 | |
| 225 | // Update the write barrier. |
| 226 | __ RecordWriteContextSlot( |
| 227 | cp, target.offset(), r0, r3, kLRHasBeenSaved, kDontSaveFPRegs); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 232 | Variable* arguments = scope()->arguments(); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 233 | if (arguments != NULL) { |
| 234 | // Function uses arguments object. |
| 235 | Comment cmnt(masm_, "[ Allocate arguments object"); |
| 236 | if (!function_in_register) { |
| 237 | // Load this again, if it's used by the local context below. |
| 238 | __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 239 | } else { |
| 240 | __ mov(r3, r1); |
| 241 | } |
| 242 | // Receiver is just before the parameters on the caller's stack. |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 243 | int num_parameters = info->scope()->num_parameters(); |
| 244 | int offset = num_parameters * kPointerSize; |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 245 | __ add(r2, fp, |
| 246 | Operand(StandardFrameConstants::kCallerSPOffset + offset)); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 247 | __ mov(r1, Operand(Smi::FromInt(num_parameters))); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 248 | __ Push(r3, r2, r1); |
| 249 | |
| 250 | // Arguments to ArgumentsAccessStub: |
| 251 | // function, receiver address, parameter count. |
| 252 | // The stub will rewrite receiever and parameter count if the previous |
| 253 | // stack frame was an arguments adapter frame. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 254 | ArgumentsAccessStub::Type type; |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 255 | if (!is_classic_mode()) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 256 | type = ArgumentsAccessStub::NEW_STRICT; |
| 257 | } else if (function()->has_duplicate_parameters()) { |
| 258 | type = ArgumentsAccessStub::NEW_NON_STRICT_SLOW; |
| 259 | } else { |
| 260 | type = ArgumentsAccessStub::NEW_NON_STRICT_FAST; |
| 261 | } |
| 262 | ArgumentsAccessStub stub(type); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 263 | __ CallStub(&stub); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 264 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 265 | SetVar(arguments, r0, r1, r2); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 266 | } |
| 267 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 268 | if (FLAG_trace) { |
| 269 | __ CallRuntime(Runtime::kTraceEnter, 0); |
| 270 | } |
| 271 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 272 | // Visit the declarations and body unless there is an illegal |
| 273 | // redeclaration. |
| 274 | if (scope()->HasIllegalRedeclaration()) { |
| 275 | Comment cmnt(masm_, "[ Declarations"); |
| 276 | scope()->VisitIllegalRedeclaration(this); |
| 277 | |
| 278 | } else { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 279 | PrepareForBailoutForId(BailoutId::FunctionEntry(), NO_REGISTERS); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 280 | { Comment cmnt(masm_, "[ Declarations"); |
| 281 | // For named function expressions, declare the function name as a |
| 282 | // constant. |
| 283 | if (scope()->is_function_scope() && scope()->function() != NULL) { |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 284 | VariableDeclaration* function = scope()->function(); |
| 285 | ASSERT(function->proxy()->var()->mode() == CONST || |
| 286 | function->proxy()->var()->mode() == CONST_HARMONY); |
| 287 | ASSERT(function->proxy()->var()->location() != Variable::UNALLOCATED); |
| 288 | VisitVariableDeclaration(function); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 289 | } |
| 290 | VisitDeclarations(scope()->declarations()); |
| 291 | } |
| 292 | |
| 293 | { Comment cmnt(masm_, "[ Stack check"); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 294 | PrepareForBailoutForId(BailoutId::Declarations(), NO_REGISTERS); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 295 | Label ok; |
| 296 | __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
| 297 | __ cmp(sp, Operand(ip)); |
| 298 | __ b(hs, &ok); |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 299 | PredictableCodeSizeScope predictable(masm_, 2 * Assembler::kInstrSize); |
jkummerow@chromium.org | dc94e19 | 2013-08-30 11:35:42 +0000 | [diff] [blame] | 300 | __ Call(isolate()->builtins()->StackCheck(), RelocInfo::CODE_TARGET); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 301 | __ bind(&ok); |
| 302 | } |
| 303 | |
| 304 | { Comment cmnt(masm_, "[ Body"); |
| 305 | ASSERT(loop_depth() == 0); |
| 306 | VisitStatements(function()->body()); |
| 307 | ASSERT(loop_depth() == 0); |
| 308 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 309 | } |
| 310 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 311 | // Always emit a 'return undefined' in case control fell off the end of |
| 312 | // the body. |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 313 | { Comment cmnt(masm_, "[ return <undefined>;"); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 314 | __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 315 | } |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 316 | EmitReturnSequence(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 317 | |
| 318 | // Force emit the constant pool, so it doesn't get emitted in the middle |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 319 | // of the back edge table. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 320 | masm()->CheckConstPool(true, false); |
| 321 | } |
| 322 | |
| 323 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 324 | void FullCodeGenerator::ClearAccumulator() { |
| 325 | __ mov(r0, Operand(Smi::FromInt(0))); |
| 326 | } |
| 327 | |
| 328 | |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 329 | void FullCodeGenerator::EmitProfilingCounterDecrement(int delta) { |
| 330 | __ mov(r2, Operand(profiling_counter_)); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 331 | __ ldr(r3, FieldMemOperand(r2, Cell::kValueOffset)); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 332 | __ sub(r3, r3, Operand(Smi::FromInt(delta)), SetCC); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 333 | __ str(r3, FieldMemOperand(r2, Cell::kValueOffset)); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | |
| 337 | void FullCodeGenerator::EmitProfilingCounterReset() { |
| 338 | int reset_value = FLAG_interrupt_budget; |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 339 | if (isolate()->IsDebuggerActive()) { |
| 340 | // Detect debug break requests as soon as possible. |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 341 | reset_value = FLAG_interrupt_budget >> 4; |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 342 | } |
| 343 | __ mov(r2, Operand(profiling_counter_)); |
| 344 | __ mov(r3, Operand(Smi::FromInt(reset_value))); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 345 | __ str(r3, FieldMemOperand(r2, Cell::kValueOffset)); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | |
rossberg@chromium.org | cddc71f | 2012-12-07 12:40:13 +0000 | [diff] [blame] | 349 | void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt, |
| 350 | Label* back_edge_target) { |
| 351 | Comment cmnt(masm_, "[ Back edge bookkeeping"); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 352 | // Block literal pools whilst emitting back edge code. |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 353 | Assembler::BlockConstPoolScope block_const_pool(masm_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 354 | Label ok; |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 355 | |
machenbach@chromium.org | afbdadc | 2013-12-09 16:12:18 +0000 | [diff] [blame] | 356 | ASSERT(back_edge_target->is_bound()); |
| 357 | int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target); |
| 358 | int weight = Min(kMaxBackEdgeWeight, |
| 359 | Max(1, distance / kCodeSizeMultiplier)); |
rossberg@chromium.org | cddc71f | 2012-12-07 12:40:13 +0000 | [diff] [blame] | 360 | EmitProfilingCounterDecrement(weight); |
| 361 | __ b(pl, &ok); |
jkummerow@chromium.org | dc94e19 | 2013-08-30 11:35:42 +0000 | [diff] [blame] | 362 | __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 363 | |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 364 | // Record a mapping of this PC offset to the OSR id. This is used to find |
| 365 | // the AST id from the unoptimized code in order to use it as a key into |
| 366 | // the deoptimization input data found in the optimized code. |
rossberg@chromium.org | cddc71f | 2012-12-07 12:40:13 +0000 | [diff] [blame] | 367 | RecordBackEdge(stmt->OsrEntryId()); |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 368 | |
rossberg@chromium.org | cddc71f | 2012-12-07 12:40:13 +0000 | [diff] [blame] | 369 | EmitProfilingCounterReset(); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 370 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 371 | __ bind(&ok); |
| 372 | PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 373 | // Record a mapping of the OSR id to this PC. This is used if the OSR |
| 374 | // entry becomes the target of a bailout. We don't expect it to be, but |
| 375 | // we want it to work if it is. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 376 | PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | |
ager@chromium.org | 2cc82ae | 2010-06-14 07:35:38 +0000 | [diff] [blame] | 380 | void FullCodeGenerator::EmitReturnSequence() { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 381 | Comment cmnt(masm_, "[ Return sequence"); |
| 382 | if (return_label_.is_bound()) { |
| 383 | __ b(&return_label_); |
| 384 | } else { |
| 385 | __ bind(&return_label_); |
| 386 | if (FLAG_trace) { |
| 387 | // Push the return value on the stack as the parameter. |
| 388 | // Runtime::TraceExit returns its parameter in r0. |
| 389 | __ push(r0); |
| 390 | __ CallRuntime(Runtime::kTraceExit, 1); |
| 391 | } |
machenbach@chromium.org | afbdadc | 2013-12-09 16:12:18 +0000 | [diff] [blame] | 392 | // Pretend that the exit is a backwards jump to the entry. |
| 393 | int weight = 1; |
| 394 | if (info_->ShouldSelfOptimize()) { |
| 395 | weight = FLAG_interrupt_budget / FLAG_self_opt_count; |
| 396 | } else { |
| 397 | int distance = masm_->pc_offset(); |
| 398 | weight = Min(kMaxBackEdgeWeight, |
| 399 | Max(1, distance / kCodeSizeMultiplier)); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 400 | } |
machenbach@chromium.org | afbdadc | 2013-12-09 16:12:18 +0000 | [diff] [blame] | 401 | EmitProfilingCounterDecrement(weight); |
| 402 | Label ok; |
| 403 | __ b(pl, &ok); |
| 404 | __ push(r0); |
| 405 | __ Call(isolate()->builtins()->InterruptCheck(), |
| 406 | RelocInfo::CODE_TARGET); |
| 407 | __ pop(r0); |
| 408 | EmitProfilingCounterReset(); |
| 409 | __ bind(&ok); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 410 | |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 411 | #ifdef DEBUG |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 412 | // Add a label for checking the size of the code used for returning. |
| 413 | Label check_exit_codesize; |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 414 | __ bind(&check_exit_codesize); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 415 | #endif |
| 416 | // Make sure that the constant pool is not emitted inside of the return |
| 417 | // sequence. |
| 418 | { Assembler::BlockConstPoolScope block_const_pool(masm_); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 419 | int32_t sp_delta = (info_->scope()->num_parameters() + 1) * kPointerSize; |
whesse@chromium.org | e90029b | 2010-08-02 11:52:17 +0000 | [diff] [blame] | 420 | CodeGenerator::RecordPositions(masm_, function()->end_position() - 1); |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 421 | // TODO(svenpanne) The code below is sometimes 4 words, sometimes 5! |
| 422 | PredictableCodeSizeScope predictable(masm_, -1); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 423 | __ RecordJSReturn(); |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 424 | int no_frame_start = __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
| 425 | __ add(sp, sp, Operand(sp_delta)); |
| 426 | __ Jump(lr); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 427 | info_->AddNoFrameRange(no_frame_start, masm_->pc_offset()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 428 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 429 | |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 430 | #ifdef DEBUG |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 431 | // Check that the size of the code used for returning is large enough |
| 432 | // for the debugger's requirements. |
| 433 | ASSERT(Assembler::kJSReturnSequenceInstructions <= |
| 434 | masm_->InstructionsGeneratedSince(&check_exit_codesize)); |
fschneider@chromium.org | 013f3e1 | 2010-04-26 13:27:52 +0000 | [diff] [blame] | 435 | #endif |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 436 | } |
| 437 | } |
| 438 | |
| 439 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 440 | void FullCodeGenerator::EffectContext::Plug(Variable* var) const { |
| 441 | ASSERT(var->IsStackAllocated() || var->IsContextSlot()); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 442 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 443 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 444 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 445 | void FullCodeGenerator::AccumulatorValueContext::Plug(Variable* var) const { |
| 446 | ASSERT(var->IsStackAllocated() || var->IsContextSlot()); |
| 447 | codegen()->GetVar(result_register(), var); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 448 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 449 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 450 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 451 | void FullCodeGenerator::StackValueContext::Plug(Variable* var) const { |
| 452 | ASSERT(var->IsStackAllocated() || var->IsContextSlot()); |
| 453 | codegen()->GetVar(result_register(), var); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 454 | __ push(result_register()); |
| 455 | } |
| 456 | |
| 457 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 458 | void FullCodeGenerator::TestContext::Plug(Variable* var) const { |
| 459 | ASSERT(var->IsStackAllocated() || var->IsContextSlot()); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 460 | // For simplicity we always test the accumulator register. |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 461 | codegen()->GetVar(result_register(), var); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 462 | codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 463 | codegen()->DoTest(this); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | |
| 467 | void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { |
| 468 | } |
| 469 | |
| 470 | |
| 471 | void FullCodeGenerator::AccumulatorValueContext::Plug( |
| 472 | Heap::RootListIndex index) const { |
| 473 | __ LoadRoot(result_register(), index); |
| 474 | } |
| 475 | |
| 476 | |
| 477 | void FullCodeGenerator::StackValueContext::Plug( |
| 478 | Heap::RootListIndex index) const { |
| 479 | __ LoadRoot(result_register(), index); |
| 480 | __ push(result_register()); |
| 481 | } |
| 482 | |
| 483 | |
| 484 | void FullCodeGenerator::TestContext::Plug(Heap::RootListIndex index) const { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 485 | codegen()->PrepareForBailoutBeforeSplit(condition(), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 486 | true, |
| 487 | true_label_, |
| 488 | false_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 489 | if (index == Heap::kUndefinedValueRootIndex || |
| 490 | index == Heap::kNullValueRootIndex || |
| 491 | index == Heap::kFalseValueRootIndex) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 492 | if (false_label_ != fall_through_) __ b(false_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 493 | } else if (index == Heap::kTrueValueRootIndex) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 494 | if (true_label_ != fall_through_) __ b(true_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 495 | } else { |
| 496 | __ LoadRoot(result_register(), index); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 497 | codegen()->DoTest(this); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 498 | } |
| 499 | } |
| 500 | |
| 501 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 502 | void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const { |
| 503 | } |
| 504 | |
| 505 | |
| 506 | void FullCodeGenerator::AccumulatorValueContext::Plug( |
| 507 | Handle<Object> lit) const { |
| 508 | __ mov(result_register(), Operand(lit)); |
| 509 | } |
| 510 | |
| 511 | |
| 512 | void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 513 | // Immediates cannot be pushed directly. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 514 | __ mov(result_register(), Operand(lit)); |
| 515 | __ push(result_register()); |
| 516 | } |
| 517 | |
| 518 | |
| 519 | void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 520 | codegen()->PrepareForBailoutBeforeSplit(condition(), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 521 | true, |
| 522 | true_label_, |
| 523 | false_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 524 | ASSERT(!lit->IsUndetectableObject()); // There are no undetectable literals. |
| 525 | if (lit->IsUndefined() || lit->IsNull() || lit->IsFalse()) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 526 | if (false_label_ != fall_through_) __ b(false_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 527 | } else if (lit->IsTrue() || lit->IsJSObject()) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 528 | if (true_label_ != fall_through_) __ b(true_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 529 | } else if (lit->IsString()) { |
| 530 | if (String::cast(*lit)->length() == 0) { |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 531 | if (false_label_ != fall_through_) __ b(false_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 532 | } else { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 533 | if (true_label_ != fall_through_) __ b(true_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 534 | } |
| 535 | } else if (lit->IsSmi()) { |
| 536 | if (Smi::cast(*lit)->value() == 0) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 537 | if (false_label_ != fall_through_) __ b(false_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 538 | } else { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 539 | if (true_label_ != fall_through_) __ b(true_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 540 | } |
| 541 | } else { |
| 542 | // For simplicity we always test the accumulator register. |
| 543 | __ mov(result_register(), Operand(lit)); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 544 | codegen()->DoTest(this); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 545 | } |
| 546 | } |
| 547 | |
| 548 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 549 | void FullCodeGenerator::EffectContext::DropAndPlug(int count, |
| 550 | Register reg) const { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 551 | ASSERT(count > 0); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 552 | __ Drop(count); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 553 | } |
| 554 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 555 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 556 | void FullCodeGenerator::AccumulatorValueContext::DropAndPlug( |
| 557 | int count, |
| 558 | Register reg) const { |
| 559 | ASSERT(count > 0); |
| 560 | __ Drop(count); |
| 561 | __ Move(result_register(), reg); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 565 | void FullCodeGenerator::StackValueContext::DropAndPlug(int count, |
| 566 | Register reg) const { |
| 567 | ASSERT(count > 0); |
| 568 | if (count > 1) __ Drop(count - 1); |
| 569 | __ str(reg, MemOperand(sp, 0)); |
| 570 | } |
| 571 | |
| 572 | |
| 573 | void FullCodeGenerator::TestContext::DropAndPlug(int count, |
| 574 | Register reg) const { |
| 575 | ASSERT(count > 0); |
| 576 | // For simplicity we always test the accumulator register. |
| 577 | __ Drop(count); |
| 578 | __ Move(result_register(), reg); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 579 | codegen()->PrepareForBailoutBeforeSplit(condition(), false, NULL, NULL); |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 580 | codegen()->DoTest(this); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 581 | } |
| 582 | |
| 583 | |
| 584 | void FullCodeGenerator::EffectContext::Plug(Label* materialize_true, |
| 585 | Label* materialize_false) const { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 586 | ASSERT(materialize_true == materialize_false); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 587 | __ bind(materialize_true); |
| 588 | } |
| 589 | |
| 590 | |
| 591 | void FullCodeGenerator::AccumulatorValueContext::Plug( |
| 592 | Label* materialize_true, |
| 593 | Label* materialize_false) const { |
| 594 | Label done; |
| 595 | __ bind(materialize_true); |
| 596 | __ LoadRoot(result_register(), Heap::kTrueValueRootIndex); |
| 597 | __ jmp(&done); |
| 598 | __ bind(materialize_false); |
| 599 | __ LoadRoot(result_register(), Heap::kFalseValueRootIndex); |
| 600 | __ bind(&done); |
| 601 | } |
| 602 | |
| 603 | |
| 604 | void FullCodeGenerator::StackValueContext::Plug( |
| 605 | Label* materialize_true, |
| 606 | Label* materialize_false) const { |
| 607 | Label done; |
| 608 | __ bind(materialize_true); |
| 609 | __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 610 | __ jmp(&done); |
| 611 | __ bind(materialize_false); |
| 612 | __ LoadRoot(ip, Heap::kFalseValueRootIndex); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 613 | __ bind(&done); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 614 | __ push(ip); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | |
| 618 | void FullCodeGenerator::TestContext::Plug(Label* materialize_true, |
| 619 | Label* materialize_false) const { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 620 | ASSERT(materialize_true == true_label_); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 621 | ASSERT(materialize_false == false_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | |
| 625 | void FullCodeGenerator::EffectContext::Plug(bool flag) const { |
| 626 | } |
| 627 | |
| 628 | |
| 629 | void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const { |
| 630 | Heap::RootListIndex value_root_index = |
| 631 | flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
| 632 | __ LoadRoot(result_register(), value_root_index); |
| 633 | } |
| 634 | |
| 635 | |
| 636 | void FullCodeGenerator::StackValueContext::Plug(bool flag) const { |
| 637 | Heap::RootListIndex value_root_index = |
| 638 | flag ? Heap::kTrueValueRootIndex : Heap::kFalseValueRootIndex; |
| 639 | __ LoadRoot(ip, value_root_index); |
| 640 | __ push(ip); |
| 641 | } |
| 642 | |
| 643 | |
| 644 | void FullCodeGenerator::TestContext::Plug(bool flag) const { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 645 | codegen()->PrepareForBailoutBeforeSplit(condition(), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 646 | true, |
| 647 | true_label_, |
| 648 | false_label_); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 649 | if (flag) { |
| 650 | if (true_label_ != fall_through_) __ b(true_label_); |
| 651 | } else { |
| 652 | if (false_label_ != fall_through_) __ b(false_label_); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 653 | } |
| 654 | } |
| 655 | |
| 656 | |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 657 | void FullCodeGenerator::DoTest(Expression* condition, |
| 658 | Label* if_true, |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 659 | Label* if_false, |
| 660 | Label* fall_through) { |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 661 | Handle<Code> ic = ToBooleanStub::GetUninitialized(isolate()); |
| 662 | CallIC(ic, RelocInfo::CODE_TARGET, condition->test_id()); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 663 | __ tst(result_register(), result_register()); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 664 | Split(ne, if_true, if_false, fall_through); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 665 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 666 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 667 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 668 | void FullCodeGenerator::Split(Condition cond, |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 669 | Label* if_true, |
| 670 | Label* if_false, |
| 671 | Label* fall_through) { |
| 672 | if (if_false == fall_through) { |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 673 | __ b(cond, if_true); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 674 | } else if (if_true == fall_through) { |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 675 | __ b(NegateCondition(cond), if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 676 | } else { |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 677 | __ b(cond, if_true); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 678 | __ b(if_false); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 679 | } |
| 680 | } |
| 681 | |
| 682 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 683 | MemOperand FullCodeGenerator::StackOperand(Variable* var) { |
| 684 | ASSERT(var->IsStackAllocated()); |
| 685 | // Offset is negative because higher indexes are at lower addresses. |
| 686 | int offset = -var->index() * kPointerSize; |
| 687 | // Adjust by a (parameter or local) base offset. |
| 688 | if (var->IsParameter()) { |
| 689 | offset += (info_->scope()->num_parameters() + 1) * kPointerSize; |
| 690 | } else { |
| 691 | offset += JavaScriptFrameConstants::kLocal0Offset; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 692 | } |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 693 | return MemOperand(fp, offset); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 694 | } |
| 695 | |
| 696 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 697 | MemOperand FullCodeGenerator::VarOperand(Variable* var, Register scratch) { |
| 698 | ASSERT(var->IsContextSlot() || var->IsStackAllocated()); |
| 699 | if (var->IsContextSlot()) { |
| 700 | int context_chain_length = scope()->ContextChainLength(var->scope()); |
| 701 | __ LoadContext(scratch, context_chain_length); |
| 702 | return ContextOperand(scratch, var->index()); |
| 703 | } else { |
| 704 | return StackOperand(var); |
| 705 | } |
| 706 | } |
| 707 | |
| 708 | |
| 709 | void FullCodeGenerator::GetVar(Register dest, Variable* var) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 710 | // Use destination as scratch. |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 711 | MemOperand location = VarOperand(var, dest); |
| 712 | __ ldr(dest, location); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 716 | void FullCodeGenerator::SetVar(Variable* var, |
| 717 | Register src, |
| 718 | Register scratch0, |
| 719 | Register scratch1) { |
| 720 | ASSERT(var->IsContextSlot() || var->IsStackAllocated()); |
| 721 | ASSERT(!scratch0.is(src)); |
| 722 | ASSERT(!scratch0.is(scratch1)); |
| 723 | ASSERT(!scratch1.is(src)); |
| 724 | MemOperand location = VarOperand(var, scratch0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 725 | __ str(src, location); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 726 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 727 | // Emit the write barrier code if the location is in the heap. |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 728 | if (var->IsContextSlot()) { |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 729 | __ RecordWriteContextSlot(scratch0, |
| 730 | location.offset(), |
| 731 | src, |
| 732 | scratch1, |
| 733 | kLRHasBeenSaved, |
| 734 | kDontSaveFPRegs); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 735 | } |
| 736 | } |
| 737 | |
| 738 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 739 | void FullCodeGenerator::PrepareForBailoutBeforeSplit(Expression* expr, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 740 | bool should_normalize, |
| 741 | Label* if_true, |
| 742 | Label* if_false) { |
| 743 | // Only prepare for bailouts before splits if we're in a test |
| 744 | // context. Otherwise, we let the Visit function deal with the |
| 745 | // preparation to avoid preparing with the same AST id twice. |
| 746 | if (!context()->IsTest() || !info_->IsOptimizable()) return; |
| 747 | |
| 748 | Label skip; |
| 749 | if (should_normalize) __ b(&skip); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 750 | PrepareForBailout(expr, TOS_REG); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 751 | if (should_normalize) { |
| 752 | __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
| 753 | __ cmp(r0, ip); |
| 754 | Split(eq, if_true, if_false, NULL); |
| 755 | __ bind(&skip); |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 760 | void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { |
| 761 | // The variable in the declaration always resides in the current function |
| 762 | // context. |
| 763 | ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); |
jkummerow@chromium.org | 000f7fb | 2012-08-01 11:14:42 +0000 | [diff] [blame] | 764 | if (generate_debug_code_) { |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 765 | // Check that we're not inside a with or catch context. |
| 766 | __ ldr(r1, FieldMemOperand(cp, HeapObject::kMapOffset)); |
| 767 | __ CompareRoot(r1, Heap::kWithContextMapRootIndex); |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 768 | __ Check(ne, kDeclarationInWithContext); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 769 | __ CompareRoot(r1, Heap::kCatchContextMapRootIndex); |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 770 | __ Check(ne, kDeclarationInCatchContext); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 771 | } |
| 772 | } |
| 773 | |
| 774 | |
| 775 | void FullCodeGenerator::VisitVariableDeclaration( |
| 776 | VariableDeclaration* declaration) { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 777 | // If it was not possible to allocate the variable at compile time, we |
| 778 | // need to "declare" it at runtime to make sure it actually exists in the |
| 779 | // local context. |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 780 | VariableProxy* proxy = declaration->proxy(); |
| 781 | VariableMode mode = declaration->mode(); |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 782 | Variable* variable = proxy->var(); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 783 | bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 784 | switch (variable->location()) { |
| 785 | case Variable::UNALLOCATED: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 786 | globals_->Add(variable->name(), zone()); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 787 | globals_->Add(variable->binding_needs_init() |
| 788 | ? isolate()->factory()->the_hole_value() |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 789 | : isolate()->factory()->undefined_value(), |
| 790 | zone()); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 791 | break; |
| 792 | |
| 793 | case Variable::PARAMETER: |
| 794 | case Variable::LOCAL: |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 795 | if (hole_init) { |
| 796 | Comment cmnt(masm_, "[ VariableDeclaration"); |
yangguo@chromium.org | 80c42ed | 2011-08-31 09:03:56 +0000 | [diff] [blame] | 797 | __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 798 | __ str(ip, StackOperand(variable)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 799 | } |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 800 | break; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 801 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 802 | case Variable::CONTEXT: |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 803 | if (hole_init) { |
| 804 | Comment cmnt(masm_, "[ VariableDeclaration"); |
| 805 | EmitDebugCheckDeclarationContext(variable); |
yangguo@chromium.org | 80c42ed | 2011-08-31 09:03:56 +0000 | [diff] [blame] | 806 | __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 807 | __ str(ip, ContextOperand(cp, variable->index())); |
yangguo@chromium.org | 80c42ed | 2011-08-31 09:03:56 +0000 | [diff] [blame] | 808 | // No write barrier since the_hole_value is in old space. |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 809 | PrepareForBailoutForId(proxy->id(), NO_REGISTERS); |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 810 | } |
| 811 | break; |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 812 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 813 | case Variable::LOOKUP: { |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 814 | Comment cmnt(masm_, "[ VariableDeclaration"); |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 815 | __ mov(r2, Operand(variable->name())); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 816 | // Declaration nodes are always introduced in one of four modes. |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 817 | ASSERT(IsDeclaredVariableMode(mode)); |
| 818 | PropertyAttributes attr = |
| 819 | IsImmutableVariableMode(mode) ? READ_ONLY : NONE; |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 820 | __ mov(r1, Operand(Smi::FromInt(attr))); |
| 821 | // Push initial value, if any. |
| 822 | // Note: For variables we must not push an initial value (such as |
| 823 | // 'undefined') because we may have a (legal) redeclaration and we |
| 824 | // must not destroy the current value. |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 825 | if (hole_init) { |
yangguo@chromium.org | 80c42ed | 2011-08-31 09:03:56 +0000 | [diff] [blame] | 826 | __ LoadRoot(r0, Heap::kTheHoleValueRootIndex); |
| 827 | __ Push(cp, r2, r1, r0); |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 828 | } else { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 829 | __ mov(r0, Operand(Smi::FromInt(0))); // Indicates no initial value. |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 830 | __ Push(cp, r2, r1, r0); |
| 831 | } |
| 832 | __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
| 833 | break; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 834 | } |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 839 | void FullCodeGenerator::VisitFunctionDeclaration( |
| 840 | FunctionDeclaration* declaration) { |
| 841 | VariableProxy* proxy = declaration->proxy(); |
| 842 | Variable* variable = proxy->var(); |
| 843 | switch (variable->location()) { |
| 844 | case Variable::UNALLOCATED: { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 845 | globals_->Add(variable->name(), zone()); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 846 | Handle<SharedFunctionInfo> function = |
| 847 | Compiler::BuildFunctionInfo(declaration->fun(), script()); |
| 848 | // Check for stack-overflow exception. |
| 849 | if (function.is_null()) return SetStackOverflow(); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 850 | globals_->Add(function, zone()); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 851 | break; |
| 852 | } |
| 853 | |
| 854 | case Variable::PARAMETER: |
| 855 | case Variable::LOCAL: { |
| 856 | Comment cmnt(masm_, "[ FunctionDeclaration"); |
| 857 | VisitForAccumulatorValue(declaration->fun()); |
| 858 | __ str(result_register(), StackOperand(variable)); |
| 859 | break; |
| 860 | } |
| 861 | |
| 862 | case Variable::CONTEXT: { |
| 863 | Comment cmnt(masm_, "[ FunctionDeclaration"); |
| 864 | EmitDebugCheckDeclarationContext(variable); |
| 865 | VisitForAccumulatorValue(declaration->fun()); |
| 866 | __ str(result_register(), ContextOperand(cp, variable->index())); |
| 867 | int offset = Context::SlotOffset(variable->index()); |
| 868 | // We know that we have written a function, which is not a smi. |
| 869 | __ RecordWriteContextSlot(cp, |
| 870 | offset, |
| 871 | result_register(), |
| 872 | r2, |
| 873 | kLRHasBeenSaved, |
| 874 | kDontSaveFPRegs, |
| 875 | EMIT_REMEMBERED_SET, |
| 876 | OMIT_SMI_CHECK); |
| 877 | PrepareForBailoutForId(proxy->id(), NO_REGISTERS); |
| 878 | break; |
| 879 | } |
| 880 | |
| 881 | case Variable::LOOKUP: { |
| 882 | Comment cmnt(masm_, "[ FunctionDeclaration"); |
| 883 | __ mov(r2, Operand(variable->name())); |
| 884 | __ mov(r1, Operand(Smi::FromInt(NONE))); |
| 885 | __ Push(cp, r2, r1); |
| 886 | // Push initial value for function declaration. |
| 887 | VisitForStackValue(declaration->fun()); |
| 888 | __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
| 889 | break; |
| 890 | } |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | |
| 895 | void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 896 | Variable* variable = declaration->proxy()->var(); |
| 897 | ASSERT(variable->location() == Variable::CONTEXT); |
| 898 | ASSERT(variable->interface()->IsFrozen()); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 899 | |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 900 | Comment cmnt(masm_, "[ ModuleDeclaration"); |
| 901 | EmitDebugCheckDeclarationContext(variable); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 902 | |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 903 | // Load instance object. |
| 904 | __ LoadContext(r1, scope_->ContextChainLength(scope_->GlobalScope())); |
| 905 | __ ldr(r1, ContextOperand(r1, variable->interface()->Index())); |
| 906 | __ ldr(r1, ContextOperand(r1, Context::EXTENSION_INDEX)); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 907 | |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 908 | // Assign it. |
| 909 | __ str(r1, ContextOperand(cp, variable->index())); |
| 910 | // We know that we have written a module, which is not a smi. |
| 911 | __ RecordWriteContextSlot(cp, |
| 912 | Context::SlotOffset(variable->index()), |
| 913 | r1, |
| 914 | r3, |
| 915 | kLRHasBeenSaved, |
| 916 | kDontSaveFPRegs, |
| 917 | EMIT_REMEMBERED_SET, |
| 918 | OMIT_SMI_CHECK); |
| 919 | PrepareForBailoutForId(declaration->proxy()->id(), NO_REGISTERS); |
| 920 | |
| 921 | // Traverse into body. |
| 922 | Visit(declaration->module()); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | |
| 926 | void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { |
| 927 | VariableProxy* proxy = declaration->proxy(); |
| 928 | Variable* variable = proxy->var(); |
| 929 | switch (variable->location()) { |
| 930 | case Variable::UNALLOCATED: |
| 931 | // TODO(rossberg) |
| 932 | break; |
| 933 | |
| 934 | case Variable::CONTEXT: { |
| 935 | Comment cmnt(masm_, "[ ImportDeclaration"); |
| 936 | EmitDebugCheckDeclarationContext(variable); |
| 937 | // TODO(rossberg) |
| 938 | break; |
| 939 | } |
| 940 | |
| 941 | case Variable::PARAMETER: |
| 942 | case Variable::LOCAL: |
| 943 | case Variable::LOOKUP: |
| 944 | UNREACHABLE(); |
| 945 | } |
| 946 | } |
| 947 | |
| 948 | |
| 949 | void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) { |
| 950 | // TODO(rossberg) |
| 951 | } |
| 952 | |
| 953 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 954 | void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
| 955 | // Call the runtime to declare the globals. |
| 956 | // The context is the first argument. |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 957 | __ mov(r1, Operand(pairs)); |
| 958 | __ mov(r0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); |
| 959 | __ Push(cp, r1, r0); |
| 960 | __ CallRuntime(Runtime::kDeclareGlobals, 3); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 961 | // Return value is ignored. |
| 962 | } |
| 963 | |
| 964 | |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 965 | void FullCodeGenerator::DeclareModules(Handle<FixedArray> descriptions) { |
| 966 | // Call the runtime to declare the modules. |
| 967 | __ Push(descriptions); |
| 968 | __ CallRuntime(Runtime::kDeclareModules, 1); |
| 969 | // Return value is ignored. |
| 970 | } |
| 971 | |
| 972 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 973 | void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 974 | Comment cmnt(masm_, "[ SwitchStatement"); |
| 975 | Breakable nested_statement(this, stmt); |
| 976 | SetStatementPosition(stmt); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 977 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 978 | // Keep the switch value on the stack until a case matches. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 979 | VisitForStackValue(stmt->tag()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 980 | PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); |
| 981 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 982 | ZoneList<CaseClause*>* clauses = stmt->cases(); |
| 983 | CaseClause* default_clause = NULL; // Can occur anywhere in the list. |
| 984 | |
| 985 | Label next_test; // Recycled for each test. |
| 986 | // Compile all the tests with branches to their bodies. |
| 987 | for (int i = 0; i < clauses->length(); i++) { |
| 988 | CaseClause* clause = clauses->at(i); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 989 | clause->body_target()->Unuse(); |
fschneider@chromium.org | d218783 | 2011-01-26 15:44:20 +0000 | [diff] [blame] | 990 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 991 | // The default is not a test, but remember it as final fall through. |
| 992 | if (clause->is_default()) { |
| 993 | default_clause = clause; |
| 994 | continue; |
| 995 | } |
| 996 | |
| 997 | Comment cmnt(masm_, "[ Case comparison"); |
| 998 | __ bind(&next_test); |
| 999 | next_test.Unuse(); |
| 1000 | |
| 1001 | // Compile the label expression. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1002 | VisitForAccumulatorValue(clause->label()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1003 | |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1004 | // Perform the comparison as if via '==='. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1005 | __ ldr(r1, MemOperand(sp, 0)); // Switch value. |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 1006 | bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1007 | JumpPatchSite patch_site(masm_); |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 1008 | if (inline_smi_code) { |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1009 | Label slow_case; |
| 1010 | __ orr(r2, r1, r0); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1011 | patch_site.EmitJumpIfNotSmi(r2, &slow_case); |
| 1012 | |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1013 | __ cmp(r1, r0); |
| 1014 | __ b(ne, &next_test); |
| 1015 | __ Drop(1); // Switch value is no longer needed. |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 1016 | __ b(clause->body_target()); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1017 | __ bind(&slow_case); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1018 | } |
| 1019 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1020 | // Record position before stub call for type feedback. |
| 1021 | SetSourcePosition(clause->position()); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 1022 | Handle<Code> ic = CompareIC::GetUninitialized(isolate(), Token::EQ_STRICT); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 1023 | CallIC(ic, RelocInfo::CODE_TARGET, clause->CompareId()); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 1024 | patch_site.EmitPatchInfo(); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1025 | |
hpayer@chromium.org | 4f99be9 | 2013-12-18 16:23:55 +0000 | [diff] [blame] | 1026 | Label skip; |
| 1027 | __ b(&skip); |
| 1028 | PrepareForBailout(clause, TOS_REG); |
| 1029 | __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
| 1030 | __ cmp(r0, ip); |
| 1031 | __ b(ne, &next_test); |
| 1032 | __ Drop(1); |
| 1033 | __ jmp(clause->body_target()); |
| 1034 | __ bind(&skip); |
| 1035 | |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 1036 | __ cmp(r0, Operand::Zero()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1037 | __ b(ne, &next_test); |
| 1038 | __ Drop(1); // Switch value is no longer needed. |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 1039 | __ b(clause->body_target()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1040 | } |
| 1041 | |
| 1042 | // Discard the test value and jump to the default if present, otherwise to |
| 1043 | // the end of the statement. |
| 1044 | __ bind(&next_test); |
| 1045 | __ Drop(1); // Switch value is no longer needed. |
| 1046 | if (default_clause == NULL) { |
rossberg@chromium.org | 28a3708 | 2011-08-22 11:03:23 +0000 | [diff] [blame] | 1047 | __ b(nested_statement.break_label()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1048 | } else { |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 1049 | __ b(default_clause->body_target()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1050 | } |
| 1051 | |
| 1052 | // Compile all the case bodies. |
| 1053 | for (int i = 0; i < clauses->length(); i++) { |
| 1054 | Comment cmnt(masm_, "[ Case body"); |
| 1055 | CaseClause* clause = clauses->at(i); |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 1056 | __ bind(clause->body_target()); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 1057 | PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1058 | VisitStatements(clause->statements()); |
| 1059 | } |
| 1060 | |
rossberg@chromium.org | 28a3708 | 2011-08-22 11:03:23 +0000 | [diff] [blame] | 1061 | __ bind(nested_statement.break_label()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1062 | PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1063 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1064 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1065 | |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1066 | void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1067 | Comment cmnt(masm_, "[ ForInStatement"); |
| 1068 | SetStatementPosition(stmt); |
| 1069 | |
| 1070 | Label loop, exit; |
| 1071 | ForIn loop_statement(this, stmt); |
| 1072 | increment_loop_depth(); |
| 1073 | |
danno@chromium.org | 1fd77d5 | 2013-06-07 16:01:45 +0000 | [diff] [blame] | 1074 | // Get the object to enumerate over. If the object is null or undefined, skip |
| 1075 | // over the loop. See ECMA-262 version 5, section 12.6.4. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1076 | VisitForAccumulatorValue(stmt->enumerable()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1077 | __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
| 1078 | __ cmp(r0, ip); |
| 1079 | __ b(eq, &exit); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1080 | Register null_value = r5; |
| 1081 | __ LoadRoot(null_value, Heap::kNullValueRootIndex); |
| 1082 | __ cmp(r0, null_value); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1083 | __ b(eq, &exit); |
| 1084 | |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 1085 | PrepareForBailoutForId(stmt->PrepareId(), TOS_REG); |
| 1086 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1087 | // Convert the object to a JS object. |
| 1088 | Label convert, done_convert; |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1089 | __ JumpIfSmi(r0, &convert); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1090 | __ CompareObjectType(r0, r1, r1, FIRST_SPEC_OBJECT_TYPE); |
| 1091 | __ b(ge, &done_convert); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1092 | __ bind(&convert); |
| 1093 | __ push(r0); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1094 | __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1095 | __ bind(&done_convert); |
| 1096 | __ push(r0); |
| 1097 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1098 | // Check for proxies. |
| 1099 | Label call_runtime; |
| 1100 | STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); |
| 1101 | __ CompareObjectType(r0, r1, r1, LAST_JS_PROXY_TYPE); |
| 1102 | __ b(le, &call_runtime); |
| 1103 | |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1104 | // Check cache validity in generated code. This is a fast case for |
| 1105 | // the JSObject::IsSimpleEnum cache validity checks. If we cannot |
| 1106 | // guarantee cache validity, call the runtime system to check cache |
| 1107 | // validity or get the property names in a fixed array. |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 1108 | __ CheckEnumCache(null_value, &call_runtime); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1109 | |
| 1110 | // The enum cache is valid. Load the map of the object being |
| 1111 | // iterated over and use the cache for the iteration. |
| 1112 | Label use_cache; |
| 1113 | __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 1114 | __ b(&use_cache); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1115 | |
| 1116 | // Get the set of properties to enumerate. |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1117 | __ bind(&call_runtime); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1118 | __ push(r0); // Duplicate the enumerable object on the stack. |
| 1119 | __ CallRuntime(Runtime::kGetPropertyNamesFast, 1); |
| 1120 | |
| 1121 | // If we got a map from the runtime call, we can do a fast |
| 1122 | // modification check. Otherwise, we got a fixed array, and we have |
| 1123 | // to do a slow check. |
| 1124 | Label fixed_array; |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 1125 | __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1126 | __ LoadRoot(ip, Heap::kMetaMapRootIndex); |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 1127 | __ cmp(r2, ip); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1128 | __ b(ne, &fixed_array); |
| 1129 | |
| 1130 | // We got a map in register r0. Get the enumeration cache from it. |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 1131 | Label no_descriptors; |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1132 | __ bind(&use_cache); |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 1133 | |
| 1134 | __ EnumLength(r1, r0); |
| 1135 | __ cmp(r1, Operand(Smi::FromInt(0))); |
| 1136 | __ b(eq, &no_descriptors); |
| 1137 | |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 1138 | __ LoadInstanceDescriptors(r0, r2); |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 1139 | __ ldr(r2, FieldMemOperand(r2, DescriptorArray::kEnumCacheOffset)); |
| 1140 | __ ldr(r2, FieldMemOperand(r2, DescriptorArray::kEnumCacheBridgeCacheOffset)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1141 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1142 | // Set up the four remaining stack slots. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1143 | __ push(r0); // Map. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1144 | __ mov(r0, Operand(Smi::FromInt(0))); |
| 1145 | // Push enumeration cache, enumeration cache length (as smi) and zero. |
| 1146 | __ Push(r2, r1, r0); |
| 1147 | __ jmp(&loop); |
| 1148 | |
yangguo@chromium.org | 355cfd1 | 2012-08-29 15:32:24 +0000 | [diff] [blame] | 1149 | __ bind(&no_descriptors); |
| 1150 | __ Drop(1); |
| 1151 | __ jmp(&exit); |
| 1152 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1153 | // We got a fixed array in register r0. Iterate through that. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1154 | Label non_proxy; |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1155 | __ bind(&fixed_array); |
ulan@chromium.org | 9a21ec4 | 2012-03-06 08:42:24 +0000 | [diff] [blame] | 1156 | |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1157 | Handle<Cell> cell = isolate()->factory()->NewCell( |
| 1158 | Handle<Object>(Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker), |
| 1159 | isolate())); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1160 | RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell); |
bmeurer@chromium.org | e94b5ff | 2013-10-25 09:22:31 +0000 | [diff] [blame] | 1161 | __ Move(r1, cell); |
ulan@chromium.org | 9a21ec4 | 2012-03-06 08:42:24 +0000 | [diff] [blame] | 1162 | __ mov(r2, Operand(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker))); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1163 | __ str(r2, FieldMemOperand(r1, Cell::kValueOffset)); |
ulan@chromium.org | 9a21ec4 | 2012-03-06 08:42:24 +0000 | [diff] [blame] | 1164 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1165 | __ mov(r1, Operand(Smi::FromInt(1))); // Smi indicates slow check |
| 1166 | __ ldr(r2, MemOperand(sp, 0 * kPointerSize)); // Get enumerated object |
| 1167 | STATIC_ASSERT(FIRST_JS_PROXY_TYPE == FIRST_SPEC_OBJECT_TYPE); |
| 1168 | __ CompareObjectType(r2, r3, r3, LAST_JS_PROXY_TYPE); |
| 1169 | __ b(gt, &non_proxy); |
| 1170 | __ mov(r1, Operand(Smi::FromInt(0))); // Zero indicates proxy |
| 1171 | __ bind(&non_proxy); |
| 1172 | __ Push(r1, r0); // Smi and array |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1173 | __ ldr(r1, FieldMemOperand(r0, FixedArray::kLengthOffset)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1174 | __ mov(r0, Operand(Smi::FromInt(0))); |
| 1175 | __ Push(r1, r0); // Fixed array length (as smi) and initial index. |
| 1176 | |
| 1177 | // Generate code for doing the condition check. |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 1178 | PrepareForBailoutForId(stmt->BodyId(), NO_REGISTERS); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1179 | __ bind(&loop); |
| 1180 | // Load the current count to r0, load the length to r1. |
| 1181 | __ Ldrd(r0, r1, MemOperand(sp, 0 * kPointerSize)); |
| 1182 | __ cmp(r0, r1); // Compare to the array length. |
rossberg@chromium.org | 28a3708 | 2011-08-22 11:03:23 +0000 | [diff] [blame] | 1183 | __ b(hs, loop_statement.break_label()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1184 | |
| 1185 | // Get the current entry of the array into register r3. |
| 1186 | __ ldr(r2, MemOperand(sp, 2 * kPointerSize)); |
| 1187 | __ add(r2, r2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 1188 | __ ldr(r3, MemOperand::PointerAddressFromSmiKey(r2, r0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1189 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1190 | // Get the expected map from the stack or a smi in the |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1191 | // permanent slow case into register r2. |
| 1192 | __ ldr(r2, MemOperand(sp, 3 * kPointerSize)); |
| 1193 | |
| 1194 | // Check if the expected map still matches that of the enumerable. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1195 | // If not, we may have to filter the key. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1196 | Label update_each; |
| 1197 | __ ldr(r1, MemOperand(sp, 4 * kPointerSize)); |
| 1198 | __ ldr(r4, FieldMemOperand(r1, HeapObject::kMapOffset)); |
| 1199 | __ cmp(r4, Operand(r2)); |
| 1200 | __ b(eq, &update_each); |
| 1201 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1202 | // For proxies, no filtering is done. |
| 1203 | // TODO(rossberg): What if only a prototype is a proxy? Not specified yet. |
| 1204 | __ cmp(r2, Operand(Smi::FromInt(0))); |
| 1205 | __ b(eq, &update_each); |
| 1206 | |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 1207 | // Convert the entry to a string or (smi) 0 if it isn't a property |
| 1208 | // any more. If the property has been removed while iterating, we |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1209 | // just skip it. |
| 1210 | __ push(r1); // Enumerable. |
| 1211 | __ push(r3); // Current entry. |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1212 | __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 1213 | __ mov(r3, Operand(r0), SetCC); |
rossberg@chromium.org | 28a3708 | 2011-08-22 11:03:23 +0000 | [diff] [blame] | 1214 | __ b(eq, loop_statement.continue_label()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1215 | |
| 1216 | // Update the 'each' property or variable from the possibly filtered |
| 1217 | // entry in register r3. |
| 1218 | __ bind(&update_each); |
| 1219 | __ mov(result_register(), r3); |
| 1220 | // Perform the assignment as if via '='. |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1221 | { EffectContext context(this); |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 1222 | EmitAssignment(stmt->each()); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1223 | } |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1224 | |
| 1225 | // Generate code for the body of the loop. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1226 | Visit(stmt->body()); |
| 1227 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1228 | // Generate code for the going to the next element by incrementing |
| 1229 | // the index (smi) stored on top of the stack. |
rossberg@chromium.org | 28a3708 | 2011-08-22 11:03:23 +0000 | [diff] [blame] | 1230 | __ bind(loop_statement.continue_label()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1231 | __ pop(r0); |
| 1232 | __ add(r0, r0, Operand(Smi::FromInt(1))); |
| 1233 | __ push(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1234 | |
rossberg@chromium.org | cddc71f | 2012-12-07 12:40:13 +0000 | [diff] [blame] | 1235 | EmitBackEdgeBookkeeping(stmt, &loop); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1236 | __ b(&loop); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1237 | |
| 1238 | // Remove the pointers stored on the stack. |
rossberg@chromium.org | 28a3708 | 2011-08-22 11:03:23 +0000 | [diff] [blame] | 1239 | __ bind(loop_statement.break_label()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1240 | __ Drop(5); |
| 1241 | |
| 1242 | // Exit and decrement the loop depth. |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 1243 | PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1244 | __ bind(&exit); |
| 1245 | decrement_loop_depth(); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1246 | } |
| 1247 | |
| 1248 | |
danno@chromium.org | 1fd77d5 | 2013-06-07 16:01:45 +0000 | [diff] [blame] | 1249 | void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) { |
| 1250 | Comment cmnt(masm_, "[ ForOfStatement"); |
| 1251 | SetStatementPosition(stmt); |
| 1252 | |
| 1253 | Iteration loop_statement(this, stmt); |
| 1254 | increment_loop_depth(); |
| 1255 | |
| 1256 | // var iterator = iterable[@@iterator]() |
| 1257 | VisitForAccumulatorValue(stmt->assign_iterator()); |
| 1258 | |
| 1259 | // As with for-in, skip the loop if the iterator is null or undefined. |
| 1260 | __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); |
| 1261 | __ b(eq, loop_statement.break_label()); |
| 1262 | __ CompareRoot(r0, Heap::kNullValueRootIndex); |
| 1263 | __ b(eq, loop_statement.break_label()); |
| 1264 | |
| 1265 | // Convert the iterator to a JS object. |
| 1266 | Label convert, done_convert; |
| 1267 | __ JumpIfSmi(r0, &convert); |
| 1268 | __ CompareObjectType(r0, r1, r1, FIRST_SPEC_OBJECT_TYPE); |
| 1269 | __ b(ge, &done_convert); |
| 1270 | __ bind(&convert); |
| 1271 | __ push(r0); |
| 1272 | __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
| 1273 | __ bind(&done_convert); |
| 1274 | __ push(r0); |
| 1275 | |
| 1276 | // Loop entry. |
| 1277 | __ bind(loop_statement.continue_label()); |
| 1278 | |
| 1279 | // result = iterator.next() |
| 1280 | VisitForEffect(stmt->next_result()); |
| 1281 | |
| 1282 | // if (result.done) break; |
| 1283 | Label result_not_done; |
| 1284 | VisitForControl(stmt->result_done(), |
| 1285 | loop_statement.break_label(), |
| 1286 | &result_not_done, |
| 1287 | &result_not_done); |
| 1288 | __ bind(&result_not_done); |
| 1289 | |
| 1290 | // each = result.value |
| 1291 | VisitForEffect(stmt->assign_each()); |
| 1292 | |
| 1293 | // Generate code for the body of the loop. |
| 1294 | Visit(stmt->body()); |
| 1295 | |
| 1296 | // Check stack before looping. |
| 1297 | PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS); |
| 1298 | EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label()); |
| 1299 | __ jmp(loop_statement.continue_label()); |
| 1300 | |
| 1301 | // Exit and decrement the loop depth. |
| 1302 | PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
| 1303 | __ bind(loop_statement.break_label()); |
| 1304 | decrement_loop_depth(); |
| 1305 | } |
| 1306 | |
| 1307 | |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1308 | void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info, |
| 1309 | bool pretenure) { |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1310 | // Use the fast case closure allocation code that allocates in new |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1311 | // space for nested functions that don't need literals cloning. If |
| 1312 | // we're running with the --always-opt or the --prepare-always-opt |
| 1313 | // flag, we need to use the runtime function so that the new function |
| 1314 | // we are creating here gets a chance to have its code optimized and |
| 1315 | // doesn't just get a copy of the existing unoptimized code. |
| 1316 | if (!FLAG_always_opt && |
| 1317 | !FLAG_prepare_always_opt && |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1318 | !pretenure && |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1319 | scope()->is_function_scope() && |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1320 | info->num_literals() == 0) { |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 1321 | FastNewClosureStub stub(info->language_mode(), info->is_generator()); |
verwaest@chromium.org | 662436e | 2013-08-28 08:41:27 +0000 | [diff] [blame] | 1322 | __ mov(r2, Operand(info)); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1323 | __ CallStub(&stub); |
| 1324 | } else { |
| 1325 | __ mov(r0, Operand(info)); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 1326 | __ LoadRoot(r1, pretenure ? Heap::kTrueValueRootIndex |
| 1327 | : Heap::kFalseValueRootIndex); |
| 1328 | __ Push(cp, r0, r1); |
| 1329 | __ CallRuntime(Runtime::kNewClosure, 3); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1330 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1331 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1332 | } |
| 1333 | |
| 1334 | |
| 1335 | void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) { |
| 1336 | Comment cmnt(masm_, "[ VariableProxy"); |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 1337 | EmitVariableLoad(expr); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1338 | } |
| 1339 | |
| 1340 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1341 | void FullCodeGenerator::EmitLoadGlobalCheckExtensions(Variable* var, |
| 1342 | TypeofState typeof_state, |
| 1343 | Label* slow) { |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1344 | Register current = cp; |
| 1345 | Register next = r1; |
| 1346 | Register temp = r2; |
| 1347 | |
| 1348 | Scope* s = scope(); |
| 1349 | while (s != NULL) { |
| 1350 | if (s->num_heap_slots() > 0) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1351 | if (s->calls_non_strict_eval()) { |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1352 | // Check that extension is NULL. |
| 1353 | __ ldr(temp, ContextOperand(current, Context::EXTENSION_INDEX)); |
| 1354 | __ tst(temp, temp); |
| 1355 | __ b(ne, slow); |
| 1356 | } |
| 1357 | // Load next context in chain. |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1358 | __ ldr(next, ContextOperand(current, Context::PREVIOUS_INDEX)); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1359 | // Walk the rest of the chain without clobbering cp. |
| 1360 | current = next; |
| 1361 | } |
| 1362 | // If no outer scope calls eval, we do not need to check more |
| 1363 | // context extensions. |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1364 | if (!s->outer_scope_calls_non_strict_eval() || s->is_eval_scope()) break; |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1365 | s = s->outer_scope(); |
| 1366 | } |
| 1367 | |
| 1368 | if (s->is_eval_scope()) { |
| 1369 | Label loop, fast; |
| 1370 | if (!current.is(next)) { |
| 1371 | __ Move(next, current); |
| 1372 | } |
| 1373 | __ bind(&loop); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 1374 | // Terminate at native context. |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1375 | __ ldr(temp, FieldMemOperand(next, HeapObject::kMapOffset)); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 1376 | __ LoadRoot(ip, Heap::kNativeContextMapRootIndex); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1377 | __ cmp(temp, ip); |
| 1378 | __ b(eq, &fast); |
| 1379 | // Check that extension is NULL. |
| 1380 | __ ldr(temp, ContextOperand(next, Context::EXTENSION_INDEX)); |
| 1381 | __ tst(temp, temp); |
| 1382 | __ b(ne, slow); |
| 1383 | // Load next context in chain. |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1384 | __ ldr(next, ContextOperand(next, Context::PREVIOUS_INDEX)); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1385 | __ b(&loop); |
| 1386 | __ bind(&fast); |
| 1387 | } |
| 1388 | |
| 1389 | __ ldr(r0, GlobalObjectOperand()); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1390 | __ mov(r2, Operand(var->name())); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1391 | RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF) |
| 1392 | ? RelocInfo::CODE_TARGET |
| 1393 | : RelocInfo::CODE_TARGET_CONTEXT; |
| 1394 | Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 1395 | CallIC(ic, mode); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1396 | } |
| 1397 | |
| 1398 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1399 | MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, |
| 1400 | Label* slow) { |
| 1401 | ASSERT(var->IsContextSlot()); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1402 | Register context = cp; |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1403 | Register next = r3; |
| 1404 | Register temp = r4; |
| 1405 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1406 | for (Scope* s = scope(); s != var->scope(); s = s->outer_scope()) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1407 | if (s->num_heap_slots() > 0) { |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1408 | if (s->calls_non_strict_eval()) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1409 | // Check that extension is NULL. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1410 | __ ldr(temp, ContextOperand(context, Context::EXTENSION_INDEX)); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1411 | __ tst(temp, temp); |
| 1412 | __ b(ne, slow); |
| 1413 | } |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame] | 1414 | __ ldr(next, ContextOperand(context, Context::PREVIOUS_INDEX)); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1415 | // Walk the rest of the chain without clobbering cp. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1416 | context = next; |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1417 | } |
| 1418 | } |
| 1419 | // Check that last extension is NULL. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1420 | __ ldr(temp, ContextOperand(context, Context::EXTENSION_INDEX)); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1421 | __ tst(temp, temp); |
| 1422 | __ b(ne, slow); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1423 | |
| 1424 | // This function is used only for loads, not stores, so it's safe to |
| 1425 | // return an cp-based operand (the write barrier cannot be allowed to |
| 1426 | // destroy the cp register). |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1427 | return ContextOperand(context, var->index()); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1428 | } |
| 1429 | |
| 1430 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1431 | void FullCodeGenerator::EmitDynamicLookupFastCase(Variable* var, |
| 1432 | TypeofState typeof_state, |
| 1433 | Label* slow, |
| 1434 | Label* done) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1435 | // Generate fast-case code for variables that might be shadowed by |
| 1436 | // eval-introduced variables. Eval is used a lot without |
| 1437 | // introducing variables. In those cases, we do not want to |
| 1438 | // perform a runtime call for all variables in the scope |
| 1439 | // containing the eval. |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 1440 | if (var->mode() == DYNAMIC_GLOBAL) { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1441 | EmitLoadGlobalCheckExtensions(var, typeof_state, slow); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1442 | __ jmp(done); |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 1443 | } else if (var->mode() == DYNAMIC_LOCAL) { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1444 | Variable* local = var->local_if_not_shadowed(); |
| 1445 | __ ldr(r0, ContextSlotOperandCheckExtensions(local, slow)); |
ulan@chromium.org | 8e8d882 | 2012-11-23 14:36:46 +0000 | [diff] [blame] | 1446 | if (local->mode() == LET || |
| 1447 | local->mode() == CONST || |
| 1448 | local->mode() == CONST_HARMONY) { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1449 | __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 1450 | if (local->mode() == CONST) { |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 1451 | __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1452 | } else { // LET || CONST_HARMONY |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame] | 1453 | __ b(ne, done); |
| 1454 | __ mov(r0, Operand(var->name())); |
| 1455 | __ push(r0); |
| 1456 | __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 1457 | } |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1458 | } |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1459 | __ jmp(done); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 1460 | } |
| 1461 | } |
| 1462 | |
| 1463 | |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 1464 | void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { |
| 1465 | // Record position before possible IC call. |
| 1466 | SetSourcePosition(proxy->position()); |
| 1467 | Variable* var = proxy->var(); |
| 1468 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1469 | // Three cases: global variables, lookup variables, and all other types of |
| 1470 | // variables. |
| 1471 | switch (var->location()) { |
| 1472 | case Variable::UNALLOCATED: { |
| 1473 | Comment cmnt(masm_, "Global variable"); |
| 1474 | // Use inline caching. Variable name is passed in r2 and the global |
| 1475 | // object (receiver) in r0. |
| 1476 | __ ldr(r0, GlobalObjectOperand()); |
| 1477 | __ mov(r2, Operand(var->name())); |
| 1478 | Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 1479 | CallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1480 | context()->Plug(r0); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1481 | break; |
| 1482 | } |
| 1483 | |
| 1484 | case Variable::PARAMETER: |
| 1485 | case Variable::LOCAL: |
| 1486 | case Variable::CONTEXT: { |
| 1487 | Comment cmnt(masm_, var->IsContextSlot() |
| 1488 | ? "Context variable" |
| 1489 | : "Stack variable"); |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1490 | if (var->binding_needs_init()) { |
| 1491 | // var->scope() may be NULL when the proxy is located in eval code and |
| 1492 | // refers to a potential outside binding. Currently those bindings are |
| 1493 | // always looked up dynamically, i.e. in that case |
| 1494 | // var->location() == LOOKUP. |
| 1495 | // always holds. |
| 1496 | ASSERT(var->scope() != NULL); |
| 1497 | |
| 1498 | // Check if the binding really needs an initialization check. The check |
| 1499 | // can be skipped in the following situation: we have a LET or CONST |
| 1500 | // binding in harmony mode, both the Variable and the VariableProxy have |
| 1501 | // the same declaration scope (i.e. they are both in global code, in the |
| 1502 | // same function or in the same eval code) and the VariableProxy is in |
| 1503 | // the source physically located after the initializer of the variable. |
| 1504 | // |
| 1505 | // We cannot skip any initialization checks for CONST in non-harmony |
| 1506 | // mode because const variables may be declared but never initialized: |
| 1507 | // if (false) { const x; }; var y = x; |
| 1508 | // |
| 1509 | // The condition on the declaration scopes is a conservative check for |
| 1510 | // nested functions that access a binding and are called before the |
| 1511 | // binding is initialized: |
| 1512 | // function() { f(); let x = 1; function f() { x = 2; } } |
| 1513 | // |
| 1514 | bool skip_init_check; |
| 1515 | if (var->scope()->DeclarationScope() != scope()->DeclarationScope()) { |
| 1516 | skip_init_check = false; |
jkummerow@chromium.org | ac45fed | 2011-11-07 13:11:02 +0000 | [diff] [blame] | 1517 | } else { |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1518 | // Check that we always have valid source position. |
| 1519 | ASSERT(var->initializer_position() != RelocInfo::kNoPosition); |
| 1520 | ASSERT(proxy->position() != RelocInfo::kNoPosition); |
| 1521 | skip_init_check = var->mode() != CONST && |
| 1522 | var->initializer_position() < proxy->position(); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1523 | } |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1524 | |
| 1525 | if (!skip_init_check) { |
| 1526 | // Let and const need a read barrier. |
| 1527 | GetVar(r0, var); |
| 1528 | __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); |
| 1529 | if (var->mode() == LET || var->mode() == CONST_HARMONY) { |
| 1530 | // Throw a reference error when using an uninitialized let/const |
| 1531 | // binding in harmony mode. |
| 1532 | Label done; |
| 1533 | __ b(ne, &done); |
| 1534 | __ mov(r0, Operand(var->name())); |
| 1535 | __ push(r0); |
| 1536 | __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 1537 | __ bind(&done); |
| 1538 | } else { |
| 1539 | // Uninitalized const bindings outside of harmony mode are unholed. |
| 1540 | ASSERT(var->mode() == CONST); |
| 1541 | __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); |
| 1542 | } |
| 1543 | context()->Plug(r0); |
| 1544 | break; |
| 1545 | } |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1546 | } |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1547 | context()->Plug(var); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 1548 | break; |
| 1549 | } |
| 1550 | |
| 1551 | case Variable::LOOKUP: { |
| 1552 | Label done, slow; |
| 1553 | // Generate code for loading from variables potentially shadowed |
| 1554 | // by eval-introduced variables. |
| 1555 | EmitDynamicLookupFastCase(var, NOT_INSIDE_TYPEOF, &slow, &done); |
| 1556 | __ bind(&slow); |
| 1557 | Comment cmnt(masm_, "Lookup variable"); |
| 1558 | __ mov(r1, Operand(var->name())); |
| 1559 | __ Push(cp, r1); // Context and name. |
| 1560 | __ CallRuntime(Runtime::kLoadContextSlot, 2); |
yangguo@chromium.org | 80c42ed | 2011-08-31 09:03:56 +0000 | [diff] [blame] | 1561 | __ bind(&done); |
| 1562 | context()->Plug(r0); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1563 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1564 | } |
| 1565 | } |
| 1566 | |
| 1567 | |
| 1568 | void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 1569 | Comment cmnt(masm_, "[ RegExpLiteral"); |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 1570 | Label materialized; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1571 | // Registers will be used as follows: |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1572 | // r5 = materialized value (RegExp literal) |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1573 | // r4 = JS function, literals array |
| 1574 | // r3 = literal index |
| 1575 | // r2 = RegExp pattern |
| 1576 | // r1 = RegExp flags |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1577 | // r0 = RegExp literal clone |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1578 | __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1579 | __ ldr(r4, FieldMemOperand(r0, JSFunction::kLiteralsOffset)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1580 | int literal_offset = |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1581 | FixedArray::kHeaderSize + expr->literal_index() * kPointerSize; |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1582 | __ ldr(r5, FieldMemOperand(r4, literal_offset)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1583 | __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1584 | __ cmp(r5, ip); |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 1585 | __ b(ne, &materialized); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1586 | |
| 1587 | // Create regexp literal using runtime function. |
| 1588 | // Result will be in r0. |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1589 | __ mov(r3, Operand(Smi::FromInt(expr->literal_index()))); |
| 1590 | __ mov(r2, Operand(expr->pattern())); |
| 1591 | __ mov(r1, Operand(expr->flags())); |
lrn@chromium.org | c34f580 | 2010-04-28 12:53:43 +0000 | [diff] [blame] | 1592 | __ Push(r4, r3, r2, r1); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1593 | __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1594 | __ mov(r5, r0); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1595 | |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 1596 | __ bind(&materialized); |
| 1597 | int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize; |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1598 | Label allocated, runtime_allocate; |
svenpanne@chromium.org | 2bda543 | 2013-03-15 12:39:50 +0000 | [diff] [blame] | 1599 | __ Allocate(size, r0, r2, r3, &runtime_allocate, TAG_OBJECT); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1600 | __ jmp(&allocated); |
| 1601 | |
| 1602 | __ bind(&runtime_allocate); |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 1603 | __ mov(r0, Operand(Smi::FromInt(size))); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 1604 | __ Push(r5, r0); |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 1605 | __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1606 | __ pop(r5); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1607 | |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1608 | __ bind(&allocated); |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 1609 | // After this, registers are used as follows: |
| 1610 | // r0: Newly allocated regexp. |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 1611 | // r5: Materialized regexp. |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 1612 | // r2: temp. |
jkummerow@chromium.org | fb732b1 | 2013-07-26 10:27:09 +0000 | [diff] [blame] | 1613 | __ CopyFields(r0, r5, d0, size / kPointerSize); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1614 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1615 | } |
| 1616 | |
| 1617 | |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 1618 | void FullCodeGenerator::EmitAccessor(Expression* expression) { |
| 1619 | if (expression == NULL) { |
| 1620 | __ LoadRoot(r1, Heap::kNullValueRootIndex); |
| 1621 | __ push(r1); |
| 1622 | } else { |
| 1623 | VisitForStackValue(expression); |
| 1624 | } |
| 1625 | } |
| 1626 | |
| 1627 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1628 | void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 1629 | Comment cmnt(masm_, "[ ObjectLiteral"); |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 1630 | |
machenbach@chromium.org | 7ff7607 | 2013-11-21 09:47:43 +0000 | [diff] [blame] | 1631 | expr->BuildConstantProperties(isolate()); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1632 | Handle<FixedArray> constant_properties = expr->constant_properties(); |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 1633 | __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 1634 | __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); |
| 1635 | __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1636 | __ mov(r1, Operand(constant_properties)); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1637 | int flags = expr->fast_elements() |
| 1638 | ? ObjectLiteral::kFastElements |
| 1639 | : ObjectLiteral::kNoFlags; |
| 1640 | flags |= expr->has_function() |
| 1641 | ? ObjectLiteral::kHasFunction |
| 1642 | : ObjectLiteral::kNoFlags; |
| 1643 | __ mov(r0, Operand(Smi::FromInt(flags))); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1644 | int properties_count = constant_properties->length() / 2; |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 1645 | if ((FLAG_track_double_fields && expr->may_store_doubles()) || |
machenbach@chromium.org | 7ff7607 | 2013-11-21 09:47:43 +0000 | [diff] [blame] | 1646 | expr->depth() > 1 || Serializer::enabled() || |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1647 | flags != ObjectLiteral::kFastElements || |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1648 | properties_count > FastCloneShallowObjectStub::kMaximumClonedProperties) { |
mstarzinger@chromium.org | 71fc346 | 2013-02-27 09:34:27 +0000 | [diff] [blame] | 1649 | __ Push(r3, r2, r1, r0); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 1650 | __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1651 | } else { |
| 1652 | FastCloneShallowObjectStub stub(properties_count); |
| 1653 | __ CallStub(&stub); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1654 | } |
| 1655 | |
| 1656 | // If result_saved is true the result is on top of the stack. If |
| 1657 | // result_saved is false the result is in r0. |
| 1658 | bool result_saved = false; |
| 1659 | |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 1660 | // Mark all computed expressions that are bound to a key that |
| 1661 | // is shadowed by a later occurrence of the same key. For the |
| 1662 | // marked expressions, no store code is emitted. |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 1663 | expr->CalculateEmitStore(zone()); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 1664 | |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 1665 | AccessorTable accessor_table(zone()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1666 | for (int i = 0; i < expr->properties()->length(); i++) { |
| 1667 | ObjectLiteral::Property* property = expr->properties()->at(i); |
| 1668 | if (property->IsCompileTimeValue()) continue; |
| 1669 | |
| 1670 | Literal* key = property->key(); |
| 1671 | Expression* value = property->value(); |
| 1672 | if (!result_saved) { |
| 1673 | __ push(r0); // Save result on stack |
| 1674 | result_saved = true; |
| 1675 | } |
| 1676 | switch (property->kind()) { |
| 1677 | case ObjectLiteral::Property::CONSTANT: |
| 1678 | UNREACHABLE(); |
| 1679 | case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 1680 | ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value())); |
| 1681 | // Fall through. |
| 1682 | case ObjectLiteral::Property::COMPUTED: |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1683 | if (key->value()->IsInternalizedString()) { |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 1684 | if (property->emit_store()) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1685 | VisitForAccumulatorValue(value); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1686 | __ mov(r2, Operand(key->value())); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1687 | __ ldr(r1, MemOperand(sp)); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1688 | Handle<Code> ic = is_classic_mode() |
| 1689 | ? isolate()->builtins()->StoreIC_Initialize() |
| 1690 | : isolate()->builtins()->StoreIC_Initialize_Strict(); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1691 | CallIC(ic, RelocInfo::CODE_TARGET, key->LiteralFeedbackId()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1692 | PrepareForBailoutForId(key->id(), NO_REGISTERS); |
| 1693 | } else { |
| 1694 | VisitForEffect(value); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 1695 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1696 | break; |
| 1697 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1698 | // Duplicate receiver on stack. |
| 1699 | __ ldr(r0, MemOperand(sp)); |
| 1700 | __ push(r0); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1701 | VisitForStackValue(key); |
| 1702 | VisitForStackValue(value); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 1703 | if (property->emit_store()) { |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 1704 | __ mov(r0, Operand(Smi::FromInt(NONE))); // PropertyAttributes |
| 1705 | __ push(r0); |
| 1706 | __ CallRuntime(Runtime::kSetProperty, 4); |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 1707 | } else { |
| 1708 | __ Drop(3); |
| 1709 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1710 | break; |
ulan@chromium.org | 750145a | 2013-03-07 15:14:13 +0000 | [diff] [blame] | 1711 | case ObjectLiteral::Property::PROTOTYPE: |
| 1712 | // Duplicate receiver on stack. |
| 1713 | __ ldr(r0, MemOperand(sp)); |
| 1714 | __ push(r0); |
| 1715 | VisitForStackValue(value); |
| 1716 | if (property->emit_store()) { |
| 1717 | __ CallRuntime(Runtime::kSetPrototype, 2); |
| 1718 | } else { |
| 1719 | __ Drop(2); |
| 1720 | } |
| 1721 | break; |
| 1722 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1723 | case ObjectLiteral::Property::GETTER: |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 1724 | accessor_table.lookup(key)->second->getter = value; |
| 1725 | break; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1726 | case ObjectLiteral::Property::SETTER: |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 1727 | accessor_table.lookup(key)->second->setter = value; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1728 | break; |
| 1729 | } |
| 1730 | } |
| 1731 | |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 1732 | // Emit code to define accessors, using only a single call to the runtime for |
| 1733 | // each pair of corresponding getters and setters. |
| 1734 | for (AccessorTable::Iterator it = accessor_table.begin(); |
| 1735 | it != accessor_table.end(); |
| 1736 | ++it) { |
| 1737 | __ ldr(r0, MemOperand(sp)); // Duplicate receiver. |
| 1738 | __ push(r0); |
| 1739 | VisitForStackValue(it->first); |
| 1740 | EmitAccessor(it->second->getter); |
| 1741 | EmitAccessor(it->second->setter); |
| 1742 | __ mov(r0, Operand(Smi::FromInt(NONE))); |
| 1743 | __ push(r0); |
| 1744 | __ CallRuntime(Runtime::kDefineOrRedefineAccessorProperty, 5); |
| 1745 | } |
| 1746 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1747 | if (expr->has_function()) { |
| 1748 | ASSERT(result_saved); |
| 1749 | __ ldr(r0, MemOperand(sp)); |
| 1750 | __ push(r0); |
| 1751 | __ CallRuntime(Runtime::kToFastProperties, 1); |
| 1752 | } |
| 1753 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1754 | if (result_saved) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1755 | context()->PlugTOS(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1756 | } else { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1757 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1758 | } |
| 1759 | } |
| 1760 | |
| 1761 | |
| 1762 | void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { |
| 1763 | Comment cmnt(masm_, "[ ArrayLiteral"); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1764 | |
machenbach@chromium.org | 7ff7607 | 2013-11-21 09:47:43 +0000 | [diff] [blame] | 1765 | expr->BuildConstantElements(isolate()); |
machenbach@chromium.org | 37be408 | 2013-11-26 13:50:38 +0000 | [diff] [blame] | 1766 | int flags = expr->depth() == 1 |
| 1767 | ? ArrayLiteral::kShallowElements |
| 1768 | : ArrayLiteral::kNoFlags; |
| 1769 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1770 | ZoneList<Expression*>* subexprs = expr->values(); |
| 1771 | int length = subexprs->length(); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1772 | Handle<FixedArray> constant_elements = expr->constant_elements(); |
| 1773 | ASSERT_EQ(2, constant_elements->length()); |
| 1774 | ElementsKind constant_elements_kind = |
| 1775 | static_cast<ElementsKind>(Smi::cast(constant_elements->get(0))->value()); |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 1776 | bool has_fast_elements = IsFastObjectElementsKind(constant_elements_kind); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1777 | Handle<FixedArrayBase> constant_elements_values( |
| 1778 | FixedArrayBase::cast(constant_elements->get(1))); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1779 | |
machenbach@chromium.org | c86e8c2 | 2013-11-27 15:11:04 +0000 | [diff] [blame] | 1780 | AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites |
| 1781 | ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE; |
| 1782 | if (has_fast_elements && !FLAG_allocation_site_pretenuring) { |
| 1783 | // If the only customer of allocation sites is transitioning, then |
| 1784 | // we can turn it off if we don't have anywhere else to transition to. |
| 1785 | allocation_site_mode = DONT_TRACK_ALLOCATION_SITE; |
| 1786 | } |
| 1787 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1788 | __ ldr(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1789 | __ ldr(r3, FieldMemOperand(r3, JSFunction::kLiteralsOffset)); |
| 1790 | __ mov(r2, Operand(Smi::FromInt(expr->literal_index()))); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1791 | __ mov(r1, Operand(constant_elements)); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1792 | if (has_fast_elements && constant_elements_values->map() == |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1793 | isolate()->heap()->fixed_cow_array_map()) { |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 1794 | FastCloneShallowArrayStub stub( |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 1795 | FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, |
machenbach@chromium.org | c86e8c2 | 2013-11-27 15:11:04 +0000 | [diff] [blame] | 1796 | allocation_site_mode, |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 1797 | length); |
ricow@chromium.org | 0b9f850 | 2010-08-18 07:45:01 +0000 | [diff] [blame] | 1798 | __ CallStub(&stub); |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1799 | __ IncrementCounter( |
| 1800 | isolate()->counters()->cow_arrays_created_stub(), 1, r1, r2); |
machenbach@chromium.org | 7ff7607 | 2013-11-21 09:47:43 +0000 | [diff] [blame] | 1801 | } else if (expr->depth() > 1 || Serializer::enabled() || |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 1802 | length > FastCloneShallowArrayStub::kMaximumClonedLength) { |
machenbach@chromium.org | 37be408 | 2013-11-26 13:50:38 +0000 | [diff] [blame] | 1803 | __ mov(r0, Operand(Smi::FromInt(flags))); |
| 1804 | __ Push(r3, r2, r1, r0); |
| 1805 | __ CallRuntime(Runtime::kCreateArrayLiteral, 4); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1806 | } else { |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 1807 | ASSERT(IsFastSmiOrObjectElementsKind(constant_elements_kind) || |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 1808 | FLAG_smi_only_arrays); |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 1809 | FastCloneShallowArrayStub::Mode mode = |
| 1810 | FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS; |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 1811 | |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 1812 | if (has_fast_elements) { |
| 1813 | mode = FastCloneShallowArrayStub::CLONE_ELEMENTS; |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 1814 | } |
| 1815 | |
yangguo@chromium.org | 46a2a51 | 2013-01-18 16:29:40 +0000 | [diff] [blame] | 1816 | FastCloneShallowArrayStub stub(mode, allocation_site_mode, length); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1817 | __ CallStub(&stub); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1818 | } |
| 1819 | |
| 1820 | bool result_saved = false; // Is the result saved to the stack? |
| 1821 | |
| 1822 | // Emit code to evaluate all the non-constant subexpressions and to store |
| 1823 | // them into the newly cloned array. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 1824 | for (int i = 0; i < length; i++) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1825 | Expression* subexpr = subexprs->at(i); |
| 1826 | // If the subexpression is a literal or a simple materialized literal it |
| 1827 | // is already set in the cloned array. |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1828 | if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1829 | |
| 1830 | if (!result_saved) { |
| 1831 | __ push(r0); |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1832 | __ Push(Smi::FromInt(expr->literal_index())); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1833 | result_saved = true; |
| 1834 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1835 | VisitForAccumulatorValue(subexpr); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1836 | |
svenpanne@chromium.org | 830d30c | 2012-05-29 13:20:14 +0000 | [diff] [blame] | 1837 | if (IsFastObjectElementsKind(constant_elements_kind)) { |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1838 | int offset = FixedArray::kHeaderSize + (i * kPointerSize); |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1839 | __ ldr(r6, MemOperand(sp, kPointerSize)); // Copy of array literal. |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1840 | __ ldr(r1, FieldMemOperand(r6, JSObject::kElementsOffset)); |
| 1841 | __ str(result_register(), FieldMemOperand(r1, offset)); |
| 1842 | // Update the write barrier for the array store. |
| 1843 | __ RecordWriteField(r1, offset, result_register(), r2, |
| 1844 | kLRHasBeenSaved, kDontSaveFPRegs, |
| 1845 | EMIT_REMEMBERED_SET, INLINE_SMI_CHECK); |
| 1846 | } else { |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1847 | __ mov(r3, Operand(Smi::FromInt(i))); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1848 | StoreArrayLiteralElementStub stub; |
| 1849 | __ CallStub(&stub); |
| 1850 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1851 | |
| 1852 | PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1853 | } |
| 1854 | |
| 1855 | if (result_saved) { |
dslomov@chromium.org | b752d40 | 2013-06-18 11:54:54 +0000 | [diff] [blame] | 1856 | __ pop(); // literal index |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1857 | context()->PlugTOS(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1858 | } else { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1859 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 1860 | } |
| 1861 | } |
| 1862 | |
| 1863 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1864 | void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
| 1865 | Comment cmnt(masm_, "[ Assignment"); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 1866 | // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' |
| 1867 | // on the left-hand side. |
| 1868 | if (!expr->target()->IsValidLeftHandSide()) { |
| 1869 | VisitForEffect(expr->target()); |
| 1870 | return; |
| 1871 | } |
| 1872 | |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1873 | // Left-hand side can only be a property, a global or a (parameter or local) |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1874 | // slot. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1875 | enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; |
| 1876 | LhsKind assign_type = VARIABLE; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1877 | Property* property = expr->target()->AsProperty(); |
| 1878 | if (property != NULL) { |
| 1879 | assign_type = (property->key()->IsPropertyName()) |
| 1880 | ? NAMED_PROPERTY |
| 1881 | : KEYED_PROPERTY; |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1882 | } |
| 1883 | |
| 1884 | // Evaluate LHS expression. |
| 1885 | switch (assign_type) { |
| 1886 | case VARIABLE: |
| 1887 | // Nothing to do here. |
| 1888 | break; |
| 1889 | case NAMED_PROPERTY: |
| 1890 | if (expr->is_compound()) { |
| 1891 | // We need the receiver both on the stack and in the accumulator. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1892 | VisitForAccumulatorValue(property->obj()); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1893 | __ push(result_register()); |
| 1894 | } else { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1895 | VisitForStackValue(property->obj()); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1896 | } |
| 1897 | break; |
| 1898 | case KEYED_PROPERTY: |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 1899 | if (expr->is_compound()) { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1900 | VisitForStackValue(property->obj()); |
| 1901 | VisitForAccumulatorValue(property->key()); |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 1902 | __ ldr(r1, MemOperand(sp, 0)); |
| 1903 | __ push(r0); |
| 1904 | } else { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 1905 | VisitForStackValue(property->obj()); |
| 1906 | VisitForStackValue(property->key()); |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 1907 | } |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1908 | break; |
| 1909 | } |
| 1910 | |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 1911 | // For compound assignments we need another deoptimization point after the |
| 1912 | // variable/property load. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1913 | if (expr->is_compound()) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1914 | { AccumulatorValueContext context(this); |
| 1915 | switch (assign_type) { |
| 1916 | case VARIABLE: |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 1917 | EmitVariableLoad(expr->target()->AsVariableProxy()); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 1918 | PrepareForBailout(expr->target(), TOS_REG); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1919 | break; |
| 1920 | case NAMED_PROPERTY: |
| 1921 | EmitNamedPropertyLoad(property); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1922 | PrepareForBailoutForId(property->LoadId(), TOS_REG); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1923 | break; |
| 1924 | case KEYED_PROPERTY: |
| 1925 | EmitKeyedPropertyLoad(property); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 1926 | PrepareForBailoutForId(property->LoadId(), TOS_REG); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1927 | break; |
| 1928 | } |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1929 | } |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1930 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1931 | Token::Value op = expr->binary_op(); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 1932 | __ push(r0); // Left operand goes on the stack. |
| 1933 | VisitForAccumulatorValue(expr->value()); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1934 | |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 1935 | OverwriteMode mode = expr->value()->ResultOverwriteAllowed() |
| 1936 | ? OVERWRITE_RIGHT |
| 1937 | : NO_OVERWRITE; |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1938 | SetSourcePosition(expr->position() + 1); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1939 | AccumulatorValueContext context(this); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1940 | if (ShouldInlineSmiCase(op)) { |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1941 | EmitInlineSmiBinaryOp(expr->binary_operation(), |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1942 | op, |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1943 | mode, |
| 1944 | expr->target(), |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 1945 | expr->value()); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1946 | } else { |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 1947 | EmitBinaryOp(expr->binary_operation(), op, mode); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1948 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1949 | |
| 1950 | // Deoptimization point in case the binary operation may have side effects. |
| 1951 | PrepareForBailout(expr->binary_operation(), TOS_REG); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 1952 | } else { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1953 | VisitForAccumulatorValue(expr->value()); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1954 | } |
| 1955 | |
| 1956 | // Record source position before possible IC call. |
| 1957 | SetSourcePosition(expr->position()); |
| 1958 | |
| 1959 | // Store the value. |
| 1960 | switch (assign_type) { |
| 1961 | case VARIABLE: |
| 1962 | EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 1963 | expr->op()); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1964 | PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 1965 | context()->Plug(r0); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 1966 | break; |
| 1967 | case NAMED_PROPERTY: |
| 1968 | EmitNamedPropertyAssignment(expr); |
| 1969 | break; |
| 1970 | case KEYED_PROPERTY: |
| 1971 | EmitKeyedPropertyAssignment(expr); |
| 1972 | break; |
| 1973 | } |
| 1974 | } |
| 1975 | |
| 1976 | |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 1977 | void FullCodeGenerator::VisitYield(Yield* expr) { |
| 1978 | Comment cmnt(masm_, "[ Yield"); |
| 1979 | // Evaluate yielded value first; the initial iterator definition depends on |
| 1980 | // this. It stays on the stack while we update the iterator. |
| 1981 | VisitForStackValue(expr->expression()); |
| 1982 | |
| 1983 | switch (expr->yield_kind()) { |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 1984 | case Yield::SUSPEND: |
| 1985 | // Pop value from top-of-stack slot; box result into result register. |
| 1986 | EmitCreateIteratorResult(false); |
| 1987 | __ push(result_register()); |
| 1988 | // Fall through. |
| 1989 | case Yield::INITIAL: { |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1990 | Label suspend, continuation, post_runtime, resume; |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 1991 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 1992 | __ jmp(&suspend); |
| 1993 | |
| 1994 | __ bind(&continuation); |
| 1995 | __ jmp(&resume); |
| 1996 | |
| 1997 | __ bind(&suspend); |
| 1998 | VisitForAccumulatorValue(expr->generator_object()); |
| 1999 | ASSERT(continuation.pos() > 0 && Smi::IsValid(continuation.pos())); |
| 2000 | __ mov(r1, Operand(Smi::FromInt(continuation.pos()))); |
| 2001 | __ str(r1, FieldMemOperand(r0, JSGeneratorObject::kContinuationOffset)); |
| 2002 | __ str(cp, FieldMemOperand(r0, JSGeneratorObject::kContextOffset)); |
| 2003 | __ mov(r1, cp); |
| 2004 | __ RecordWriteField(r0, JSGeneratorObject::kContextOffset, r1, r2, |
| 2005 | kLRHasBeenSaved, kDontSaveFPRegs); |
| 2006 | __ add(r1, fp, Operand(StandardFrameConstants::kExpressionsOffset)); |
| 2007 | __ cmp(sp, r1); |
| 2008 | __ b(eq, &post_runtime); |
| 2009 | __ push(r0); // generator object |
| 2010 | __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
| 2011 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2012 | __ bind(&post_runtime); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2013 | __ pop(result_register()); |
| 2014 | EmitReturnSequence(); |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2015 | |
| 2016 | __ bind(&resume); |
| 2017 | context()->Plug(result_register()); |
| 2018 | break; |
| 2019 | } |
| 2020 | |
| 2021 | case Yield::FINAL: { |
| 2022 | VisitForAccumulatorValue(expr->generator_object()); |
| 2023 | __ mov(r1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed))); |
| 2024 | __ str(r1, FieldMemOperand(result_register(), |
| 2025 | JSGeneratorObject::kContinuationOffset)); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2026 | // Pop value from top-of-stack slot, box result into result register. |
| 2027 | EmitCreateIteratorResult(true); |
| 2028 | EmitUnwindBeforeReturn(); |
| 2029 | EmitReturnSequence(); |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2030 | break; |
| 2031 | } |
| 2032 | |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2033 | case Yield::DELEGATING: { |
| 2034 | VisitForStackValue(expr->generator_object()); |
| 2035 | |
| 2036 | // Initial stack layout is as follows: |
| 2037 | // [sp + 1 * kPointerSize] iter |
| 2038 | // [sp + 0 * kPointerSize] g |
| 2039 | |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2040 | Label l_catch, l_try, l_suspend, l_continuation, l_resume; |
| 2041 | Label l_next, l_call, l_loop; |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2042 | // Initial send value is undefined. |
| 2043 | __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
verwaest@chromium.org | 8a00e82 | 2013-06-10 15:11:22 +0000 | [diff] [blame] | 2044 | __ b(&l_next); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2045 | |
danno@chromium.org | f95d4b9 | 2013-06-13 14:40:17 +0000 | [diff] [blame] | 2046 | // catch (e) { receiver = iter; f = 'throw'; arg = e; goto l_call; } |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2047 | __ bind(&l_catch); |
| 2048 | handler_table()->set(expr->index(), Smi::FromInt(l_catch.pos())); |
danno@chromium.org | f95d4b9 | 2013-06-13 14:40:17 +0000 | [diff] [blame] | 2049 | __ LoadRoot(r2, Heap::kthrow_stringRootIndex); // "throw" |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2050 | __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2051 | __ Push(r3, r0); // iter, exception |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2052 | __ jmp(&l_call); |
| 2053 | |
danno@chromium.org | f95d4b9 | 2013-06-13 14:40:17 +0000 | [diff] [blame] | 2054 | // try { received = %yield result } |
| 2055 | // Shuffle the received result above a try handler and yield it without |
| 2056 | // re-boxing. |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2057 | __ bind(&l_try); |
danno@chromium.org | f95d4b9 | 2013-06-13 14:40:17 +0000 | [diff] [blame] | 2058 | __ pop(r0); // result |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2059 | __ PushTryHandler(StackHandler::CATCH, expr->index()); |
| 2060 | const int handler_size = StackHandlerConstants::kSize; |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2061 | __ push(r0); // result |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2062 | __ jmp(&l_suspend); |
| 2063 | __ bind(&l_continuation); |
| 2064 | __ jmp(&l_resume); |
| 2065 | __ bind(&l_suspend); |
| 2066 | const int generator_object_depth = kPointerSize + handler_size; |
| 2067 | __ ldr(r0, MemOperand(sp, generator_object_depth)); |
| 2068 | __ push(r0); // g |
| 2069 | ASSERT(l_continuation.pos() > 0 && Smi::IsValid(l_continuation.pos())); |
| 2070 | __ mov(r1, Operand(Smi::FromInt(l_continuation.pos()))); |
| 2071 | __ str(r1, FieldMemOperand(r0, JSGeneratorObject::kContinuationOffset)); |
| 2072 | __ str(cp, FieldMemOperand(r0, JSGeneratorObject::kContextOffset)); |
| 2073 | __ mov(r1, cp); |
| 2074 | __ RecordWriteField(r0, JSGeneratorObject::kContextOffset, r1, r2, |
| 2075 | kLRHasBeenSaved, kDontSaveFPRegs); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2076 | __ CallRuntime(Runtime::kSuspendJSGeneratorObject, 1); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2077 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2078 | __ pop(r0); // result |
| 2079 | EmitReturnSequence(); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2080 | __ bind(&l_resume); // received in r0 |
| 2081 | __ PopTryHandler(); |
| 2082 | |
danno@chromium.org | f95d4b9 | 2013-06-13 14:40:17 +0000 | [diff] [blame] | 2083 | // receiver = iter; f = 'next'; arg = received; |
verwaest@chromium.org | 8a00e82 | 2013-06-10 15:11:22 +0000 | [diff] [blame] | 2084 | __ bind(&l_next); |
danno@chromium.org | f95d4b9 | 2013-06-13 14:40:17 +0000 | [diff] [blame] | 2085 | __ LoadRoot(r2, Heap::knext_stringRootIndex); // "next" |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2086 | __ ldr(r3, MemOperand(sp, 1 * kPointerSize)); // iter |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2087 | __ Push(r3, r0); // iter, received |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2088 | |
danno@chromium.org | f95d4b9 | 2013-06-13 14:40:17 +0000 | [diff] [blame] | 2089 | // result = receiver[f](arg); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2090 | __ bind(&l_call); |
danno@chromium.org | f95d4b9 | 2013-06-13 14:40:17 +0000 | [diff] [blame] | 2091 | Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(1); |
| 2092 | CallIC(ic); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2093 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2094 | |
danno@chromium.org | f95d4b9 | 2013-06-13 14:40:17 +0000 | [diff] [blame] | 2095 | // if (!result.done) goto l_try; |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2096 | __ bind(&l_loop); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2097 | __ push(r0); // save result |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2098 | __ LoadRoot(r2, Heap::kdone_stringRootIndex); // "done" |
| 2099 | Handle<Code> done_ic = isolate()->builtins()->LoadIC_Initialize(); |
| 2100 | CallIC(done_ic); // result.done in r0 |
rossberg@chromium.org | b99c754 | 2013-05-31 11:40:45 +0000 | [diff] [blame] | 2101 | Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
| 2102 | CallIC(bool_ic); |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2103 | __ cmp(r0, Operand(0)); |
| 2104 | __ b(eq, &l_try); |
| 2105 | |
| 2106 | // result.value |
danno@chromium.org | f95d4b9 | 2013-06-13 14:40:17 +0000 | [diff] [blame] | 2107 | __ pop(r0); // result |
| 2108 | __ LoadRoot(r2, Heap::kvalue_stringRootIndex); // "value" |
| 2109 | Handle<Code> value_ic = isolate()->builtins()->LoadIC_Initialize(); |
| 2110 | CallIC(value_ic); // result.value in r0 |
jkummerow@chromium.org | 4e308cf | 2013-05-17 13:39:16 +0000 | [diff] [blame] | 2111 | context()->DropAndPlug(2, r0); // drop iter and g |
| 2112 | break; |
| 2113 | } |
ulan@chromium.org | 77ca49a | 2013-04-22 09:43:56 +0000 | [diff] [blame] | 2114 | } |
| 2115 | } |
| 2116 | |
| 2117 | |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2118 | void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
| 2119 | Expression *value, |
| 2120 | JSGeneratorObject::ResumeMode resume_mode) { |
| 2121 | // The value stays in r0, and is ultimately read by the resumed generator, as |
| 2122 | // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. r1 |
| 2123 | // will hold the generator object until the activation has been resumed. |
| 2124 | VisitForStackValue(generator); |
| 2125 | VisitForAccumulatorValue(value); |
| 2126 | __ pop(r1); |
| 2127 | |
| 2128 | // Check generator state. |
| 2129 | Label wrong_state, done; |
| 2130 | __ ldr(r3, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset)); |
| 2131 | STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0); |
| 2132 | STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed <= 0); |
| 2133 | __ cmp(r3, Operand(Smi::FromInt(0))); |
| 2134 | __ b(le, &wrong_state); |
| 2135 | |
| 2136 | // Load suspended function and context. |
| 2137 | __ ldr(cp, FieldMemOperand(r1, JSGeneratorObject::kContextOffset)); |
| 2138 | __ ldr(r4, FieldMemOperand(r1, JSGeneratorObject::kFunctionOffset)); |
| 2139 | |
| 2140 | // Load receiver and store as the first argument. |
| 2141 | __ ldr(r2, FieldMemOperand(r1, JSGeneratorObject::kReceiverOffset)); |
| 2142 | __ push(r2); |
| 2143 | |
| 2144 | // Push holes for the rest of the arguments to the generator function. |
| 2145 | __ ldr(r3, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
| 2146 | __ ldr(r3, |
| 2147 | FieldMemOperand(r3, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 2148 | __ LoadRoot(r2, Heap::kTheHoleValueRootIndex); |
| 2149 | Label push_argument_holes, push_frame; |
| 2150 | __ bind(&push_argument_holes); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2151 | __ sub(r3, r3, Operand(Smi::FromInt(1)), SetCC); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2152 | __ b(mi, &push_frame); |
| 2153 | __ push(r2); |
| 2154 | __ jmp(&push_argument_holes); |
| 2155 | |
| 2156 | // Enter a new JavaScript frame, and initialize its slots as they were when |
| 2157 | // the generator was suspended. |
| 2158 | Label resume_frame; |
| 2159 | __ bind(&push_frame); |
| 2160 | __ bl(&resume_frame); |
| 2161 | __ jmp(&done); |
| 2162 | __ bind(&resume_frame); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2163 | // lr = return address. |
| 2164 | // fp = caller's frame pointer. |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 2165 | // pp = caller's constant pool (if FLAG_enable_ool_constant_pool), |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2166 | // cp = callee's context, |
| 2167 | // r4 = callee's JS function. |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 2168 | __ PushFixedFrame(r4); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2169 | // Adjust FP to point to saved FP. |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 2170 | __ add(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2171 | |
| 2172 | // Load the operand stack size. |
| 2173 | __ ldr(r3, FieldMemOperand(r1, JSGeneratorObject::kOperandStackOffset)); |
| 2174 | __ ldr(r3, FieldMemOperand(r3, FixedArray::kLengthOffset)); |
| 2175 | __ SmiUntag(r3); |
| 2176 | |
| 2177 | // If we are sending a value and there is no operand stack, we can jump back |
| 2178 | // in directly. |
verwaest@chromium.org | 8a00e82 | 2013-06-10 15:11:22 +0000 | [diff] [blame] | 2179 | if (resume_mode == JSGeneratorObject::NEXT) { |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2180 | Label slow_resume; |
| 2181 | __ cmp(r3, Operand(0)); |
| 2182 | __ b(ne, &slow_resume); |
| 2183 | __ ldr(r3, FieldMemOperand(r4, JSFunction::kCodeEntryOffset)); |
| 2184 | __ ldr(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset)); |
| 2185 | __ SmiUntag(r2); |
| 2186 | __ add(r3, r3, r2); |
| 2187 | __ mov(r2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); |
| 2188 | __ str(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset)); |
| 2189 | __ Jump(r3); |
| 2190 | __ bind(&slow_resume); |
| 2191 | } |
| 2192 | |
| 2193 | // Otherwise, we push holes for the operand stack and call the runtime to fix |
| 2194 | // up the stack and the handlers. |
| 2195 | Label push_operand_holes, call_resume; |
| 2196 | __ bind(&push_operand_holes); |
| 2197 | __ sub(r3, r3, Operand(1), SetCC); |
| 2198 | __ b(mi, &call_resume); |
| 2199 | __ push(r2); |
| 2200 | __ b(&push_operand_holes); |
| 2201 | __ bind(&call_resume); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2202 | ASSERT(!result_register().is(r1)); |
| 2203 | __ Push(r1, result_register()); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 2204 | __ Push(Smi::FromInt(resume_mode)); |
| 2205 | __ CallRuntime(Runtime::kResumeJSGeneratorObject, 3); |
| 2206 | // Not reached: the runtime call returns elsewhere. |
| 2207 | __ stop("not-reached"); |
| 2208 | |
| 2209 | // Throw error if we attempt to operate on a running generator. |
| 2210 | __ bind(&wrong_state); |
| 2211 | __ push(r1); |
| 2212 | __ CallRuntime(Runtime::kThrowGeneratorStateError, 1); |
| 2213 | |
| 2214 | __ bind(&done); |
| 2215 | context()->Plug(result_register()); |
| 2216 | } |
| 2217 | |
| 2218 | |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2219 | void FullCodeGenerator::EmitCreateIteratorResult(bool done) { |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 2220 | Label gc_required; |
| 2221 | Label allocated; |
| 2222 | |
| 2223 | Handle<Map> map(isolate()->native_context()->generator_result_map()); |
| 2224 | |
| 2225 | __ Allocate(map->instance_size(), r0, r2, r3, &gc_required, TAG_OBJECT); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2226 | __ jmp(&allocated); |
| 2227 | |
| 2228 | __ bind(&gc_required); |
| 2229 | __ Push(Smi::FromInt(map->instance_size())); |
| 2230 | __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
| 2231 | __ ldr(context_register(), |
| 2232 | MemOperand(fp, StandardFrameConstants::kContextOffset)); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 2233 | |
| 2234 | __ bind(&allocated); |
| 2235 | __ mov(r1, Operand(map)); |
| 2236 | __ pop(r2); |
| 2237 | __ mov(r3, Operand(isolate()->factory()->ToBoolean(done))); |
| 2238 | __ mov(r4, Operand(isolate()->factory()->empty_fixed_array())); |
| 2239 | ASSERT_EQ(map->instance_size(), 5 * kPointerSize); |
| 2240 | __ str(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 2241 | __ str(r4, FieldMemOperand(r0, JSObject::kPropertiesOffset)); |
| 2242 | __ str(r4, FieldMemOperand(r0, JSObject::kElementsOffset)); |
| 2243 | __ str(r2, |
| 2244 | FieldMemOperand(r0, JSGeneratorObject::kResultValuePropertyOffset)); |
| 2245 | __ str(r3, |
| 2246 | FieldMemOperand(r0, JSGeneratorObject::kResultDonePropertyOffset)); |
| 2247 | |
| 2248 | // Only the value field needs a write barrier, as the other values are in the |
| 2249 | // root set. |
| 2250 | __ RecordWriteField(r0, JSGeneratorObject::kResultValuePropertyOffset, |
| 2251 | r2, r3, kLRHasBeenSaved, kDontSaveFPRegs); |
ulan@chromium.org | 57ff881 | 2013-05-10 08:16:55 +0000 | [diff] [blame] | 2252 | } |
| 2253 | |
| 2254 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2255 | void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
| 2256 | SetSourcePosition(prop->position()); |
| 2257 | Literal* key = prop->key()->AsLiteral(); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2258 | __ mov(r2, Operand(key->value())); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2259 | // Call load IC. It has arguments receiver and property name r0 and r2. |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 2260 | Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2261 | CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2262 | } |
| 2263 | |
| 2264 | |
| 2265 | void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
| 2266 | SetSourcePosition(prop->position()); |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 2267 | // Call keyed load IC. It has arguments key and receiver in r0 and r1. |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 2268 | Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2269 | CallIC(ic, RelocInfo::CODE_TARGET, prop->PropertyFeedbackId()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2270 | } |
| 2271 | |
| 2272 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 2273 | void FullCodeGenerator::EmitInlineSmiBinaryOp(BinaryOperation* expr, |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 2274 | Token::Value op, |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 2275 | OverwriteMode mode, |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2276 | Expression* left_expr, |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 2277 | Expression* right_expr) { |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2278 | Label done, smi_case, stub_call; |
| 2279 | |
| 2280 | Register scratch1 = r2; |
| 2281 | Register scratch2 = r3; |
| 2282 | |
| 2283 | // Get the arguments. |
| 2284 | Register left = r1; |
| 2285 | Register right = r0; |
| 2286 | __ pop(left); |
| 2287 | |
| 2288 | // Perform combined smi check on both operands. |
| 2289 | __ orr(scratch1, left, Operand(right)); |
| 2290 | STATIC_ASSERT(kSmiTag == 0); |
| 2291 | JumpPatchSite patch_site(masm_); |
| 2292 | patch_site.EmitJumpIfSmi(scratch1, &smi_case); |
| 2293 | |
| 2294 | __ bind(&stub_call); |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 2295 | BinaryOpICStub stub(op, mode); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 2296 | CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2297 | expr->BinaryOperationFeedbackId()); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2298 | patch_site.EmitPatchInfo(); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2299 | __ jmp(&done); |
| 2300 | |
| 2301 | __ bind(&smi_case); |
| 2302 | // Smi case. This code works the same way as the smi-smi case in the type |
| 2303 | // recording binary operation stub, see |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2304 | switch (op) { |
| 2305 | case Token::SAR: |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2306 | __ GetLeastBitsFromSmi(scratch1, right, 5); |
| 2307 | __ mov(right, Operand(left, ASR, scratch1)); |
| 2308 | __ bic(right, right, Operand(kSmiTagMask)); |
| 2309 | break; |
| 2310 | case Token::SHL: { |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2311 | __ SmiUntag(scratch1, left); |
| 2312 | __ GetLeastBitsFromSmi(scratch2, right, 5); |
| 2313 | __ mov(scratch1, Operand(scratch1, LSL, scratch2)); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 2314 | __ TrySmiTag(right, scratch1, &stub_call); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2315 | break; |
| 2316 | } |
| 2317 | case Token::SHR: { |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2318 | __ SmiUntag(scratch1, left); |
| 2319 | __ GetLeastBitsFromSmi(scratch2, right, 5); |
| 2320 | __ mov(scratch1, Operand(scratch1, LSR, scratch2)); |
| 2321 | __ tst(scratch1, Operand(0xc0000000)); |
| 2322 | __ b(ne, &stub_call); |
| 2323 | __ SmiTag(right, scratch1); |
| 2324 | break; |
| 2325 | } |
| 2326 | case Token::ADD: |
| 2327 | __ add(scratch1, left, Operand(right), SetCC); |
| 2328 | __ b(vs, &stub_call); |
| 2329 | __ mov(right, scratch1); |
| 2330 | break; |
| 2331 | case Token::SUB: |
| 2332 | __ sub(scratch1, left, Operand(right), SetCC); |
| 2333 | __ b(vs, &stub_call); |
| 2334 | __ mov(right, scratch1); |
| 2335 | break; |
| 2336 | case Token::MUL: { |
| 2337 | __ SmiUntag(ip, right); |
| 2338 | __ smull(scratch1, scratch2, left, ip); |
| 2339 | __ mov(ip, Operand(scratch1, ASR, 31)); |
| 2340 | __ cmp(ip, Operand(scratch2)); |
| 2341 | __ b(ne, &stub_call); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 2342 | __ cmp(scratch1, Operand::Zero()); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2343 | __ mov(right, Operand(scratch1), LeaveCC, ne); |
| 2344 | __ b(ne, &done); |
| 2345 | __ add(scratch2, right, Operand(left), SetCC); |
| 2346 | __ mov(right, Operand(Smi::FromInt(0)), LeaveCC, pl); |
| 2347 | __ b(mi, &stub_call); |
| 2348 | break; |
| 2349 | } |
| 2350 | case Token::BIT_OR: |
| 2351 | __ orr(right, left, Operand(right)); |
| 2352 | break; |
| 2353 | case Token::BIT_AND: |
| 2354 | __ and_(right, left, Operand(right)); |
| 2355 | break; |
| 2356 | case Token::BIT_XOR: |
| 2357 | __ eor(right, left, Operand(right)); |
| 2358 | break; |
| 2359 | default: |
| 2360 | UNREACHABLE(); |
| 2361 | } |
| 2362 | |
| 2363 | __ bind(&done); |
| 2364 | context()->Plug(r0); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 2365 | } |
| 2366 | |
| 2367 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 2368 | void FullCodeGenerator::EmitBinaryOp(BinaryOperation* expr, |
| 2369 | Token::Value op, |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2370 | OverwriteMode mode) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2371 | __ pop(r1); |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 2372 | BinaryOpICStub stub(op, mode); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2373 | JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 2374 | CallIC(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2375 | expr->BinaryOperationFeedbackId()); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2376 | patch_site.EmitPatchInfo(); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2377 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2378 | } |
| 2379 | |
| 2380 | |
kmillikin@chromium.org | be6bd10 | 2012-02-23 08:45:21 +0000 | [diff] [blame] | 2381 | void FullCodeGenerator::EmitAssignment(Expression* expr) { |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 2382 | // Invalid left-hand sides are rewritten by the parser to have a 'throw |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2383 | // ReferenceError' on the left-hand side. |
| 2384 | if (!expr->IsValidLeftHandSide()) { |
| 2385 | VisitForEffect(expr); |
| 2386 | return; |
| 2387 | } |
| 2388 | |
| 2389 | // Left-hand side can only be a property, a global or a (parameter or local) |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2390 | // slot. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2391 | enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; |
| 2392 | LhsKind assign_type = VARIABLE; |
| 2393 | Property* prop = expr->AsProperty(); |
| 2394 | if (prop != NULL) { |
| 2395 | assign_type = (prop->key()->IsPropertyName()) |
| 2396 | ? NAMED_PROPERTY |
| 2397 | : KEYED_PROPERTY; |
| 2398 | } |
| 2399 | |
| 2400 | switch (assign_type) { |
| 2401 | case VARIABLE: { |
| 2402 | Variable* var = expr->AsVariableProxy()->var(); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2403 | EffectContext context(this); |
| 2404 | EmitVariableAssignment(var, Token::ASSIGN); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2405 | break; |
| 2406 | } |
| 2407 | case NAMED_PROPERTY: { |
| 2408 | __ push(r0); // Preserve value. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2409 | VisitForAccumulatorValue(prop->obj()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2410 | __ mov(r1, r0); |
| 2411 | __ pop(r0); // Restore value. |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2412 | __ mov(r2, Operand(prop->key()->AsLiteral()->value())); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 2413 | Handle<Code> ic = is_classic_mode() |
| 2414 | ? isolate()->builtins()->StoreIC_Initialize() |
| 2415 | : isolate()->builtins()->StoreIC_Initialize_Strict(); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 2416 | CallIC(ic); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2417 | break; |
| 2418 | } |
| 2419 | case KEYED_PROPERTY: { |
| 2420 | __ push(r0); // Preserve value. |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 2421 | VisitForStackValue(prop->obj()); |
| 2422 | VisitForAccumulatorValue(prop->key()); |
| 2423 | __ mov(r1, r0); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2424 | __ Pop(r0, r2); // r0 = restored value. |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 2425 | Handle<Code> ic = is_classic_mode() |
| 2426 | ? isolate()->builtins()->KeyedStoreIC_Initialize() |
| 2427 | : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 2428 | CallIC(ic); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2429 | break; |
| 2430 | } |
| 2431 | } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2432 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2433 | } |
| 2434 | |
| 2435 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2436 | void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2437 | Token::Value op) { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2438 | if (var->IsUnallocated()) { |
| 2439 | // Global var, const, or let. |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2440 | __ mov(r2, Operand(var->name())); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2441 | __ ldr(r1, GlobalObjectOperand()); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 2442 | Handle<Code> ic = is_classic_mode() |
| 2443 | ? isolate()->builtins()->StoreIC_Initialize() |
| 2444 | : isolate()->builtins()->StoreIC_Initialize_Strict(); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 2445 | CallIC(ic, RelocInfo::CODE_TARGET_CONTEXT); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2446 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2447 | } else if (op == Token::INIT_CONST) { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2448 | // Const initializers need a write barrier. |
| 2449 | ASSERT(!var->IsParameter()); // No const parameters. |
| 2450 | if (var->IsStackLocal()) { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2451 | __ ldr(r1, StackOperand(var)); |
| 2452 | __ CompareRoot(r1, Heap::kTheHoleValueRootIndex); |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 2453 | __ str(result_register(), StackOperand(var), eq); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2454 | } else { |
| 2455 | ASSERT(var->IsContextSlot() || var->IsLookupSlot()); |
| 2456 | // Like var declarations, const declarations are hoisted to function |
| 2457 | // scope. However, unlike var initializers, const initializers are |
| 2458 | // able to drill a hole to that function context, even from inside a |
| 2459 | // 'with' context. We thus bypass the normal static scope lookup for |
| 2460 | // var->IsContextSlot(). |
| 2461 | __ push(r0); |
| 2462 | __ mov(r0, Operand(var->name())); |
| 2463 | __ Push(cp, r0); // Context and name. |
| 2464 | __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2465 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2466 | |
rossberg@chromium.org | b4b2aa6 | 2011-10-13 09:49:59 +0000 | [diff] [blame] | 2467 | } else if (var->mode() == LET && op != Token::INIT_LET) { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2468 | // Non-initializing assignment to let variable needs a write barrier. |
| 2469 | if (var->IsLookupSlot()) { |
| 2470 | __ push(r0); // Value. |
| 2471 | __ mov(r1, Operand(var->name())); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 2472 | __ mov(r0, Operand(Smi::FromInt(language_mode()))); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2473 | __ Push(cp, r1, r0); // Context, name, strict mode. |
| 2474 | __ CallRuntime(Runtime::kStoreContextSlot, 4); |
| 2475 | } else { |
| 2476 | ASSERT(var->IsStackAllocated() || var->IsContextSlot()); |
| 2477 | Label assign; |
| 2478 | MemOperand location = VarOperand(var, r1); |
| 2479 | __ ldr(r3, location); |
| 2480 | __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
| 2481 | __ b(ne, &assign); |
| 2482 | __ mov(r3, Operand(var->name())); |
| 2483 | __ push(r3); |
| 2484 | __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 2485 | // Perform the assignment. |
| 2486 | __ bind(&assign); |
| 2487 | __ str(result_register(), location); |
| 2488 | if (var->IsContextSlot()) { |
yangguo@chromium.org | 80c42ed | 2011-08-31 09:03:56 +0000 | [diff] [blame] | 2489 | // RecordWrite may destroy all its register arguments. |
| 2490 | __ mov(r3, result_register()); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2491 | int offset = Context::SlotOffset(var->index()); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2492 | __ RecordWriteContextSlot( |
| 2493 | r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs); |
yangguo@chromium.org | 80c42ed | 2011-08-31 09:03:56 +0000 | [diff] [blame] | 2494 | } |
yangguo@chromium.org | 80c42ed | 2011-08-31 09:03:56 +0000 | [diff] [blame] | 2495 | } |
| 2496 | |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 2497 | } else if (!var->is_const_mode() || op == Token::INIT_CONST_HARMONY) { |
| 2498 | // Assignment to var or initializing assignment to let/const |
| 2499 | // in harmony mode. |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2500 | if (var->IsStackAllocated() || var->IsContextSlot()) { |
| 2501 | MemOperand location = VarOperand(var, r1); |
jkummerow@chromium.org | 000f7fb | 2012-08-01 11:14:42 +0000 | [diff] [blame] | 2502 | if (generate_debug_code_ && op == Token::INIT_LET) { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2503 | // Check for an uninitialized let binding. |
| 2504 | __ ldr(r2, location); |
| 2505 | __ CompareRoot(r2, Heap::kTheHoleValueRootIndex); |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 2506 | __ Check(eq, kLetBindingReInitialization); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2507 | } |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2508 | // Perform the assignment. |
| 2509 | __ str(r0, location); |
| 2510 | if (var->IsContextSlot()) { |
| 2511 | __ mov(r3, r0); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 2512 | int offset = Context::SlotOffset(var->index()); |
| 2513 | __ RecordWriteContextSlot( |
| 2514 | r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2515 | } |
| 2516 | } else { |
| 2517 | ASSERT(var->IsLookupSlot()); |
| 2518 | __ push(r0); // Value. |
| 2519 | __ mov(r1, Operand(var->name())); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 2520 | __ mov(r0, Operand(Smi::FromInt(language_mode()))); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2521 | __ Push(cp, r1, r0); // Context, name, strict mode. |
| 2522 | __ CallRuntime(Runtime::kStoreContextSlot, 4); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2523 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2524 | } |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2525 | // Non-initializing assignments to consts are ignored. |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2526 | } |
| 2527 | |
| 2528 | |
| 2529 | void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
| 2530 | // Assignment to a property, using a named store IC. |
| 2531 | Property* prop = expr->target()->AsProperty(); |
| 2532 | ASSERT(prop != NULL); |
| 2533 | ASSERT(prop->key()->AsLiteral() != NULL); |
| 2534 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2535 | // Record source code position before IC call. |
| 2536 | SetSourcePosition(expr->position()); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2537 | __ mov(r2, Operand(prop->key()->AsLiteral()->value())); |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 2538 | __ pop(r1); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 2539 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 2540 | Handle<Code> ic = is_classic_mode() |
| 2541 | ? isolate()->builtins()->StoreIC_Initialize() |
| 2542 | : isolate()->builtins()->StoreIC_Initialize_Strict(); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2543 | CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2544 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2545 | PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 2546 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2547 | } |
| 2548 | |
| 2549 | |
| 2550 | void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
| 2551 | // Assignment to a property, using a keyed store IC. |
| 2552 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2553 | // Record source code position before IC call. |
| 2554 | SetSourcePosition(expr->position()); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2555 | __ Pop(r2, r1); // r1 = key. |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 2556 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 2557 | Handle<Code> ic = is_classic_mode() |
| 2558 | ? isolate()->builtins()->KeyedStoreIC_Initialize() |
| 2559 | : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2560 | CallIC(ic, RelocInfo::CODE_TARGET, expr->AssignmentFeedbackId()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2561 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2562 | PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 2563 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2564 | } |
| 2565 | |
| 2566 | |
| 2567 | void FullCodeGenerator::VisitProperty(Property* expr) { |
| 2568 | Comment cmnt(masm_, "[ Property"); |
| 2569 | Expression* key = expr->key(); |
| 2570 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2571 | if (key->IsPropertyName()) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2572 | VisitForAccumulatorValue(expr->obj()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2573 | EmitNamedPropertyLoad(expr); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2574 | PrepareForBailoutForId(expr->LoadId(), TOS_REG); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2575 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2576 | } else { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2577 | VisitForStackValue(expr->obj()); |
| 2578 | VisitForAccumulatorValue(expr->key()); |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 2579 | __ pop(r1); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2580 | EmitKeyedPropertyLoad(expr); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2581 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2582 | } |
| 2583 | } |
| 2584 | |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 2585 | |
| 2586 | void FullCodeGenerator::CallIC(Handle<Code> code, |
| 2587 | RelocInfo::Mode rmode, |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2588 | TypeFeedbackId ast_id) { |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 2589 | ic_total_count_++; |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 2590 | // All calls must have a predictable size in full-codegen code to ensure that |
| 2591 | // the debugger can patch them correctly. |
| 2592 | __ Call(code, rmode, ast_id, al, NEVER_INLINE_TARGET_ADDRESS); |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 2593 | } |
| 2594 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2595 | void FullCodeGenerator::EmitCallWithIC(Call* expr, |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 2596 | Handle<Object> name, |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2597 | RelocInfo::Mode mode) { |
| 2598 | // Code common for calls using the IC. |
| 2599 | ZoneList<Expression*>* args = expr->arguments(); |
| 2600 | int arg_count = args->length(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2601 | { PreservePositionScope scope(masm()->positions_recorder()); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 2602 | for (int i = 0; i < arg_count; i++) { |
| 2603 | VisitForStackValue(args->at(i)); |
| 2604 | } |
| 2605 | __ mov(r2, Operand(name)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2606 | } |
| 2607 | // Record source position for debugger. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2608 | SetSourcePosition(expr->position()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2609 | // Call the IC initialization code. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2610 | Handle<Code> ic = |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 2611 | isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2612 | CallIC(ic, mode, expr->CallFeedbackId()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2613 | RecordJSReturnSite(expr); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2614 | // Restore context register. |
| 2615 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2616 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2617 | } |
| 2618 | |
| 2619 | |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 2620 | void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 2621 | Expression* key) { |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2622 | // Load the key. |
| 2623 | VisitForAccumulatorValue(key); |
| 2624 | |
| 2625 | // Swap the name of the function and the receiver on the stack to follow |
| 2626 | // the calling convention for call ICs. |
| 2627 | __ pop(r1); |
| 2628 | __ push(r0); |
| 2629 | __ push(r1); |
| 2630 | |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 2631 | // Code common for calls using the IC. |
| 2632 | ZoneList<Expression*>* args = expr->arguments(); |
| 2633 | int arg_count = args->length(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2634 | { PreservePositionScope scope(masm()->positions_recorder()); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 2635 | for (int i = 0; i < arg_count; i++) { |
| 2636 | VisitForStackValue(args->at(i)); |
| 2637 | } |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 2638 | } |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 2639 | // Record source position for debugger. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2640 | SetSourcePosition(expr->position()); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 2641 | // Call the IC initialization code. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2642 | Handle<Code> ic = |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 2643 | isolate()->stub_cache()->ComputeKeyedCallInitialize(arg_count); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2644 | __ ldr(r2, MemOperand(sp, (arg_count + 1) * kPointerSize)); // Key. |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2645 | CallIC(ic, RelocInfo::CODE_TARGET, expr->CallFeedbackId()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2646 | RecordJSReturnSite(expr); |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 2647 | // Restore context register. |
| 2648 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2649 | context()->DropAndPlug(1, r0); // Drop the key still on the stack. |
whesse@chromium.org | 2c186ca | 2010-06-16 11:32:39 +0000 | [diff] [blame] | 2650 | } |
| 2651 | |
| 2652 | |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 2653 | void FullCodeGenerator::EmitCallWithStub(Call* expr, CallFunctionFlags flags) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2654 | // Code common for calls using the call stub. |
| 2655 | ZoneList<Expression*>* args = expr->arguments(); |
| 2656 | int arg_count = args->length(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2657 | { PreservePositionScope scope(masm()->positions_recorder()); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 2658 | for (int i = 0; i < arg_count; i++) { |
| 2659 | VisitForStackValue(args->at(i)); |
| 2660 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2661 | } |
| 2662 | // Record source position for debugger. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2663 | SetSourcePosition(expr->position()); |
mstarzinger@chromium.org | 88d326b | 2012-04-23 12:57:22 +0000 | [diff] [blame] | 2664 | |
jkummerow@chromium.org | 000f7fb | 2012-08-01 11:14:42 +0000 | [diff] [blame] | 2665 | // Record call targets in unoptimized code. |
| 2666 | flags = static_cast<CallFunctionFlags>(flags | RECORD_CALL_TARGET); |
| 2667 | Handle<Object> uninitialized = |
| 2668 | TypeFeedbackCells::UninitializedSentinel(isolate()); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2669 | Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2670 | RecordTypeFeedbackCell(expr->CallFeedbackId(), cell); |
jkummerow@chromium.org | 000f7fb | 2012-08-01 11:14:42 +0000 | [diff] [blame] | 2671 | __ mov(r2, Operand(cell)); |
mstarzinger@chromium.org | 88d326b | 2012-04-23 12:57:22 +0000 | [diff] [blame] | 2672 | |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 2673 | CallFunctionStub stub(arg_count, flags); |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 2674 | __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 2675 | __ CallStub(&stub, expr->CallFeedbackId()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2676 | RecordJSReturnSite(expr); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2677 | // Restore context register. |
| 2678 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2679 | context()->DropAndPlug(1, r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2680 | } |
| 2681 | |
| 2682 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2683 | void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2684 | // r4: copy of the first argument or undefined if it doesn't exist. |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 2685 | if (arg_count > 0) { |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2686 | __ ldr(r4, MemOperand(sp, arg_count * kPointerSize)); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 2687 | } else { |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2688 | __ LoadRoot(r4, Heap::kUndefinedValueRootIndex); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 2689 | } |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 2690 | |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2691 | // r3: the receiver of the enclosing function. |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 2692 | int receiver_offset = 2 + info_->scope()->num_parameters(); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2693 | __ ldr(r3, MemOperand(fp, receiver_offset * kPointerSize)); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 2694 | |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2695 | // r2: the language mode. |
| 2696 | __ mov(r2, Operand(Smi::FromInt(language_mode()))); |
| 2697 | |
| 2698 | // r1: the start position of the scope the calls resides in. |
jkummerow@chromium.org | 04e4f1e | 2011-11-14 13:36:17 +0000 | [diff] [blame] | 2699 | __ mov(r1, Operand(Smi::FromInt(scope()->start_position()))); |
jkummerow@chromium.org | 04e4f1e | 2011-11-14 13:36:17 +0000 | [diff] [blame] | 2700 | |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 2701 | // Do the runtime call. |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2702 | __ Push(r4, r3, r2, r1); |
jkummerow@chromium.org | 04e4f1e | 2011-11-14 13:36:17 +0000 | [diff] [blame] | 2703 | __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 2704 | } |
| 2705 | |
| 2706 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2707 | void FullCodeGenerator::VisitCall(Call* expr) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2708 | #ifdef DEBUG |
| 2709 | // We want to verify that RecordJSReturnSite gets called on all paths |
| 2710 | // through this function. Avoid early returns. |
| 2711 | expr->return_is_recorded_ = false; |
| 2712 | #endif |
| 2713 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2714 | Comment cmnt(masm_, "[ Call"); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2715 | Expression* callee = expr->expression(); |
| 2716 | VariableProxy* proxy = callee->AsVariableProxy(); |
| 2717 | Property* property = callee->AsProperty(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2718 | |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 2719 | if (proxy != NULL && proxy->var()->is_possibly_eval(isolate())) { |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2720 | // In a call to eval, we first call %ResolvePossiblyDirectEval to |
| 2721 | // resolve the function we need to call and the receiver of the |
| 2722 | // call. Then we call the resolved function using the given |
| 2723 | // arguments. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2724 | ZoneList<Expression*>* args = expr->arguments(); |
| 2725 | int arg_count = args->length(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2726 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2727 | { PreservePositionScope pos_scope(masm()->positions_recorder()); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2728 | VisitForStackValue(callee); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 2729 | __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
| 2730 | __ push(r2); // Reserved receiver slot. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2731 | |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 2732 | // Push the arguments. |
| 2733 | for (int i = 0; i < arg_count; i++) { |
| 2734 | VisitForStackValue(args->at(i)); |
| 2735 | } |
| 2736 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2737 | // Push a copy of the function (found below the arguments) and |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 2738 | // resolve eval. |
| 2739 | __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 2740 | __ push(r1); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2741 | EmitResolvePossiblyDirectEval(arg_count); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 2742 | |
| 2743 | // The runtime call returns a pair of values in r0 (function) and |
| 2744 | // r1 (receiver). Touch up the stack with the right values. |
| 2745 | __ str(r0, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 2746 | __ str(r1, MemOperand(sp, arg_count * kPointerSize)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2747 | } |
| 2748 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2749 | // Record source position for debugger. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2750 | SetSourcePosition(expr->position()); |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 2751 | CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT); |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 2752 | __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2753 | __ CallStub(&stub); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2754 | RecordJSReturnSite(expr); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2755 | // Restore context register. |
| 2756 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2757 | context()->DropAndPlug(1, r0); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2758 | } else if (proxy != NULL && proxy->var()->IsUnallocated()) { |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 2759 | // Push global object as receiver for the call IC. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2760 | __ ldr(r0, GlobalObjectOperand()); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 2761 | __ push(r0); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2762 | EmitCallWithIC(expr, proxy->name(), RelocInfo::CODE_TARGET_CONTEXT); |
| 2763 | } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2764 | // Call to a lookup slot (dynamically introduced variable). |
| 2765 | Label slow, done; |
| 2766 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2767 | { PreservePositionScope scope(masm()->positions_recorder()); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 2768 | // Generate code for loading from variables potentially shadowed |
| 2769 | // by eval-introduced variables. |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2770 | EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 2771 | } |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2772 | |
| 2773 | __ bind(&slow); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2774 | // Call the runtime to find the function to call (returned in r0) |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2775 | // and the object holding it (returned in edx). |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2776 | ASSERT(!context_register().is(r2)); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2777 | __ mov(r2, Operand(proxy->name())); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 2778 | __ Push(context_register(), r2); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2779 | __ CallRuntime(Runtime::kLoadContextSlot, 2); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2780 | __ Push(r0, r1); // Function, receiver. |
| 2781 | |
| 2782 | // If fast case code has been generated, emit code to push the |
| 2783 | // function and receiver and have the slow path jump around this |
| 2784 | // code. |
| 2785 | if (done.is_linked()) { |
| 2786 | Label call; |
| 2787 | __ b(&call); |
| 2788 | __ bind(&done); |
| 2789 | // Push function. |
| 2790 | __ push(r0); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 2791 | // The receiver is implicitly the global receiver. Indicate this |
| 2792 | // by passing the hole to the call function stub. |
| 2793 | __ LoadRoot(r1, Heap::kTheHoleValueRootIndex); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 2794 | __ push(r1); |
| 2795 | __ bind(&call); |
| 2796 | } |
| 2797 | |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 2798 | // The receiver is either the global receiver or an object found |
| 2799 | // by LoadContextSlot. That object could be the hole if the |
| 2800 | // receiver is implicitly the global object. |
| 2801 | EmitCallWithStub(expr, RECEIVER_MIGHT_BE_IMPLICIT); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2802 | } else if (property != NULL) { |
| 2803 | { PreservePositionScope scope(masm()->positions_recorder()); |
| 2804 | VisitForStackValue(property->obj()); |
| 2805 | } |
| 2806 | if (property->key()->IsPropertyName()) { |
| 2807 | EmitCallWithIC(expr, |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 2808 | property->key()->AsLiteral()->value(), |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2809 | RelocInfo::CODE_TARGET); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2810 | } else { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2811 | EmitKeyedCallWithIC(expr, property->key()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2812 | } |
| 2813 | } else { |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2814 | // Call to an arbitrary expression not handled specially above. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2815 | { PreservePositionScope scope(masm()->positions_recorder()); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 2816 | VisitForStackValue(callee); |
whesse@chromium.org | f0ac72d | 2010-11-08 12:47:26 +0000 | [diff] [blame] | 2817 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2818 | // Load global receiver object. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 2819 | __ ldr(r1, GlobalObjectOperand()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2820 | __ ldr(r1, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset)); |
| 2821 | __ push(r1); |
| 2822 | // Emit function call. |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 2823 | EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2824 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2825 | |
| 2826 | #ifdef DEBUG |
| 2827 | // RecordJSReturnSite should have been called. |
| 2828 | ASSERT(expr->return_is_recorded_); |
| 2829 | #endif |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2830 | } |
| 2831 | |
| 2832 | |
| 2833 | void FullCodeGenerator::VisitCallNew(CallNew* expr) { |
| 2834 | Comment cmnt(masm_, "[ CallNew"); |
| 2835 | // According to ECMA-262, section 11.2.2, page 44, the function |
| 2836 | // expression in new calls must be evaluated before the |
| 2837 | // arguments. |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2838 | |
| 2839 | // Push constructor on the stack. If it's not a function it's used as |
| 2840 | // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is |
| 2841 | // ignored. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2842 | VisitForStackValue(expr->expression()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2843 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2844 | // Push the arguments ("left-to-right") on the stack. |
| 2845 | ZoneList<Expression*>* args = expr->arguments(); |
| 2846 | int arg_count = args->length(); |
| 2847 | for (int i = 0; i < arg_count; i++) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2848 | VisitForStackValue(args->at(i)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2849 | } |
| 2850 | |
| 2851 | // Call the construct call builtin that handles allocation and |
| 2852 | // constructor invocation. |
| 2853 | SetSourcePosition(expr->position()); |
| 2854 | |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2855 | // Load function and argument count into r1 and r0. |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2856 | __ mov(r0, Operand(arg_count)); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2857 | __ ldr(r1, MemOperand(sp, arg_count * kPointerSize)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2858 | |
jkummerow@chromium.org | 000f7fb | 2012-08-01 11:14:42 +0000 | [diff] [blame] | 2859 | // Record call targets in unoptimized code. |
| 2860 | Handle<Object> uninitialized = |
| 2861 | TypeFeedbackCells::UninitializedSentinel(isolate()); |
danno@chromium.org | 4172848 | 2013-06-12 22:31:22 +0000 | [diff] [blame] | 2862 | Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 2863 | RecordTypeFeedbackCell(expr->CallNewFeedbackId(), cell); |
jkummerow@chromium.org | 000f7fb | 2012-08-01 11:14:42 +0000 | [diff] [blame] | 2864 | __ mov(r2, Operand(cell)); |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 2865 | |
jkummerow@chromium.org | 000f7fb | 2012-08-01 11:14:42 +0000 | [diff] [blame] | 2866 | CallConstructStub stub(RECORD_CALL_TARGET); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 2867 | __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 2868 | PrepareForBailoutForId(expr->ReturnId(), TOS_REG); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2869 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 2870 | } |
| 2871 | |
| 2872 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2873 | void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| 2874 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2875 | ASSERT(args->length() == 1); |
| 2876 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2877 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2878 | |
| 2879 | Label materialize_true, materialize_false; |
| 2880 | Label* if_true = NULL; |
| 2881 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2882 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2883 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 2884 | &if_true, &if_false, &fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2885 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2886 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 2887 | __ SmiTst(r0); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2888 | Split(eq, if_true, if_false, fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2889 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2890 | context()->Plug(if_true, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2891 | } |
| 2892 | |
| 2893 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2894 | void FullCodeGenerator::EmitIsNonNegativeSmi(CallRuntime* expr) { |
| 2895 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2896 | ASSERT(args->length() == 1); |
| 2897 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2898 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2899 | |
| 2900 | Label materialize_true, materialize_false; |
| 2901 | Label* if_true = NULL; |
| 2902 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2903 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2904 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 2905 | &if_true, &if_false, &fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2906 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2907 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 2908 | __ NonNegativeSmiTst(r0); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2909 | Split(eq, if_true, if_false, fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2910 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2911 | context()->Plug(if_true, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2912 | } |
| 2913 | |
| 2914 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2915 | void FullCodeGenerator::EmitIsObject(CallRuntime* expr) { |
| 2916 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2917 | ASSERT(args->length() == 1); |
| 2918 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2919 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2920 | |
| 2921 | Label materialize_true, materialize_false; |
| 2922 | Label* if_true = NULL; |
| 2923 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2924 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2925 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 2926 | &if_true, &if_false, &fall_through); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2927 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2928 | __ JumpIfSmi(r0, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2929 | __ LoadRoot(ip, Heap::kNullValueRootIndex); |
| 2930 | __ cmp(r0, ip); |
| 2931 | __ b(eq, if_true); |
| 2932 | __ ldr(r2, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 2933 | // Undetectable objects behave like undefined when tested with typeof. |
| 2934 | __ ldrb(r1, FieldMemOperand(r2, Map::kBitFieldOffset)); |
| 2935 | __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
| 2936 | __ b(ne, if_false); |
| 2937 | __ ldrb(r1, FieldMemOperand(r2, Map::kInstanceTypeOffset)); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 2938 | __ cmp(r1, Operand(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2939 | __ b(lt, if_false); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 2940 | __ cmp(r1, Operand(LAST_NONCALLABLE_SPEC_OBJECT_TYPE)); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2941 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2942 | Split(le, if_true, if_false, fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2943 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2944 | context()->Plug(if_true, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2945 | } |
| 2946 | |
| 2947 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2948 | void FullCodeGenerator::EmitIsSpecObject(CallRuntime* expr) { |
| 2949 | ZoneList<Expression*>* args = expr->arguments(); |
ricow@chromium.org | 4980dff | 2010-07-19 08:33:45 +0000 | [diff] [blame] | 2950 | ASSERT(args->length() == 1); |
| 2951 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2952 | VisitForAccumulatorValue(args->at(0)); |
ricow@chromium.org | 4980dff | 2010-07-19 08:33:45 +0000 | [diff] [blame] | 2953 | |
| 2954 | Label materialize_true, materialize_false; |
| 2955 | Label* if_true = NULL; |
| 2956 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2957 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2958 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 2959 | &if_true, &if_false, &fall_through); |
ricow@chromium.org | 4980dff | 2010-07-19 08:33:45 +0000 | [diff] [blame] | 2960 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2961 | __ JumpIfSmi(r0, if_false); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 2962 | __ CompareObjectType(r0, r1, r1, FIRST_SPEC_OBJECT_TYPE); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2963 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2964 | Split(ge, if_true, if_false, fall_through); |
ricow@chromium.org | 4980dff | 2010-07-19 08:33:45 +0000 | [diff] [blame] | 2965 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2966 | context()->Plug(if_true, if_false); |
ricow@chromium.org | 4980dff | 2010-07-19 08:33:45 +0000 | [diff] [blame] | 2967 | } |
| 2968 | |
| 2969 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2970 | void FullCodeGenerator::EmitIsUndetectableObject(CallRuntime* expr) { |
| 2971 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2972 | ASSERT(args->length() == 1); |
| 2973 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2974 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2975 | |
| 2976 | Label materialize_true, materialize_false; |
| 2977 | Label* if_true = NULL; |
| 2978 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2979 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2980 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 2981 | &if_true, &if_false, &fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2982 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2983 | __ JumpIfSmi(r0, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2984 | __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 2985 | __ ldrb(r1, FieldMemOperand(r1, Map::kBitFieldOffset)); |
| 2986 | __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2987 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 2988 | Split(ne, if_true, if_false, fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2989 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2990 | context()->Plug(if_true, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 2991 | } |
| 2992 | |
| 2993 | |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 2994 | void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf( |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2995 | CallRuntime* expr) { |
| 2996 | ZoneList<Expression*>* args = expr->arguments(); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 2997 | ASSERT(args->length() == 1); |
| 2998 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 2999 | VisitForAccumulatorValue(args->at(0)); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 3000 | |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 3001 | Label materialize_true, materialize_false, skip_lookup; |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 3002 | Label* if_true = NULL; |
| 3003 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3004 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3005 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 3006 | &if_true, &if_false, &fall_through); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 3007 | |
svenpanne@chromium.org | c859c4f | 2012-10-15 11:51:39 +0000 | [diff] [blame] | 3008 | __ AssertNotSmi(r0); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3009 | |
| 3010 | __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 3011 | __ ldrb(ip, FieldMemOperand(r1, Map::kBitField2Offset)); |
| 3012 | __ tst(ip, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 3013 | __ b(ne, &skip_lookup); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3014 | |
| 3015 | // Check for fast case object. Generate false result for slow case object. |
| 3016 | __ ldr(r2, FieldMemOperand(r0, JSObject::kPropertiesOffset)); |
| 3017 | __ ldr(r2, FieldMemOperand(r2, HeapObject::kMapOffset)); |
| 3018 | __ LoadRoot(ip, Heap::kHashTableMapRootIndex); |
| 3019 | __ cmp(r2, ip); |
| 3020 | __ b(eq, if_false); |
| 3021 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3022 | // Look for valueOf name in the descriptor array, and indicate false if |
verwaest@chromium.org | 06ab2ec | 2012-10-09 17:00:13 +0000 | [diff] [blame] | 3023 | // found. Since we omit an enumeration index check, if it is added via a |
| 3024 | // transition that shares its descriptor array, this is a false positive. |
| 3025 | Label entry, loop, done; |
| 3026 | |
| 3027 | // Skip loop if no descriptors are valid. |
| 3028 | __ NumberOfOwnDescriptors(r3, r1); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 3029 | __ cmp(r3, Operand::Zero()); |
verwaest@chromium.org | 06ab2ec | 2012-10-09 17:00:13 +0000 | [diff] [blame] | 3030 | __ b(eq, &done); |
| 3031 | |
rossberg@chromium.org | 89e18f5 | 2012-10-22 13:09:53 +0000 | [diff] [blame] | 3032 | __ LoadInstanceDescriptors(r1, r4); |
verwaest@chromium.org | 06ab2ec | 2012-10-09 17:00:13 +0000 | [diff] [blame] | 3033 | // r4: descriptor array. |
| 3034 | // r3: valid entries in the descriptor array. |
verwaest@chromium.org | 06ab2ec | 2012-10-09 17:00:13 +0000 | [diff] [blame] | 3035 | __ mov(ip, Operand(DescriptorArray::kDescriptorSize)); |
| 3036 | __ mul(r3, r3, ip); |
| 3037 | // Calculate location of the first key name. |
| 3038 | __ add(r4, r4, Operand(DescriptorArray::kFirstOffset - kHeapObjectTag)); |
| 3039 | // Calculate the end of the descriptor array. |
| 3040 | __ mov(r2, r4); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 3041 | __ add(r2, r2, Operand::PointerOffsetFromSmiKey(r3)); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3042 | |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3043 | // Loop through all the keys in the descriptor array. If one of these is the |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3044 | // string "valueOf" the result is false. |
| 3045 | // The use of ip to store the valueOf string assumes that it is not otherwise |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3046 | // used in the loop below. |
verwaest@chromium.org | d4be0f0 | 2013-06-05 13:39:03 +0000 | [diff] [blame] | 3047 | __ mov(ip, Operand(isolate()->factory()->value_of_string())); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3048 | __ jmp(&entry); |
| 3049 | __ bind(&loop); |
| 3050 | __ ldr(r3, MemOperand(r4, 0)); |
| 3051 | __ cmp(r3, ip); |
| 3052 | __ b(eq, if_false); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 3053 | __ add(r4, r4, Operand(DescriptorArray::kDescriptorSize * kPointerSize)); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3054 | __ bind(&entry); |
| 3055 | __ cmp(r4, Operand(r2)); |
| 3056 | __ b(ne, &loop); |
| 3057 | |
verwaest@chromium.org | 06ab2ec | 2012-10-09 17:00:13 +0000 | [diff] [blame] | 3058 | __ bind(&done); |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 3059 | |
| 3060 | // Set the bit in the map to indicate that there is no local valueOf field. |
| 3061 | __ ldrb(r2, FieldMemOperand(r1, Map::kBitField2Offset)); |
| 3062 | __ orr(r2, r2, Operand(1 << Map::kStringWrapperSafeForDefaultValueOf)); |
| 3063 | __ strb(r2, FieldMemOperand(r1, Map::kBitField2Offset)); |
| 3064 | |
| 3065 | __ bind(&skip_lookup); |
| 3066 | |
verwaest@chromium.org | 06ab2ec | 2012-10-09 17:00:13 +0000 | [diff] [blame] | 3067 | // If a valueOf property is not found on the object check that its |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3068 | // prototype is the un-modified String prototype. If not result is false. |
| 3069 | __ ldr(r2, FieldMemOperand(r1, Map::kPrototypeOffset)); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 3070 | __ JumpIfSmi(r2, if_false); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3071 | __ ldr(r2, FieldMemOperand(r2, HeapObject::kMapOffset)); |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 3072 | __ ldr(r3, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); |
| 3073 | __ ldr(r3, FieldMemOperand(r3, GlobalObject::kNativeContextOffset)); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3074 | __ ldr(r3, ContextOperand(r3, Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX)); |
| 3075 | __ cmp(r2, r3); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3076 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
dslomov@chromium.org | 4a35c5a | 2013-09-13 07:28:52 +0000 | [diff] [blame] | 3077 | Split(eq, if_true, if_false, fall_through); |
| 3078 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3079 | context()->Plug(if_true, if_false); |
ager@chromium.org | ea4f62e | 2010-08-16 16:28:43 +0000 | [diff] [blame] | 3080 | } |
| 3081 | |
| 3082 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3083 | void FullCodeGenerator::EmitIsFunction(CallRuntime* expr) { |
| 3084 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3085 | ASSERT(args->length() == 1); |
| 3086 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3087 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3088 | |
| 3089 | Label materialize_true, materialize_false; |
| 3090 | Label* if_true = NULL; |
| 3091 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3092 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3093 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 3094 | &if_true, &if_false, &fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3095 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3096 | __ JumpIfSmi(r0, if_false); |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 3097 | __ CompareObjectType(r0, r1, r2, JS_FUNCTION_TYPE); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3098 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3099 | Split(eq, if_true, if_false, fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3100 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3101 | context()->Plug(if_true, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3102 | } |
| 3103 | |
| 3104 | |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 3105 | void FullCodeGenerator::EmitIsMinusZero(CallRuntime* expr) { |
| 3106 | ZoneList<Expression*>* args = expr->arguments(); |
| 3107 | ASSERT(args->length() == 1); |
| 3108 | |
| 3109 | VisitForAccumulatorValue(args->at(0)); |
| 3110 | |
| 3111 | Label materialize_true, materialize_false; |
| 3112 | Label* if_true = NULL; |
| 3113 | Label* if_false = NULL; |
| 3114 | Label* fall_through = NULL; |
| 3115 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 3116 | &if_true, &if_false, &fall_through); |
| 3117 | |
| 3118 | __ CheckMap(r0, r1, Heap::kHeapNumberMapRootIndex, if_false, DO_SMI_CHECK); |
| 3119 | __ ldr(r2, FieldMemOperand(r0, HeapNumber::kExponentOffset)); |
| 3120 | __ ldr(r1, FieldMemOperand(r0, HeapNumber::kMantissaOffset)); |
| 3121 | __ cmp(r2, Operand(0x80000000)); |
| 3122 | __ cmp(r1, Operand(0x00000000), eq); |
| 3123 | |
| 3124 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
| 3125 | Split(eq, if_true, if_false, fall_through); |
| 3126 | |
| 3127 | context()->Plug(if_true, if_false); |
| 3128 | } |
| 3129 | |
| 3130 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3131 | void FullCodeGenerator::EmitIsArray(CallRuntime* expr) { |
| 3132 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3133 | ASSERT(args->length() == 1); |
| 3134 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3135 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3136 | |
| 3137 | Label materialize_true, materialize_false; |
| 3138 | Label* if_true = NULL; |
| 3139 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3140 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3141 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 3142 | &if_true, &if_false, &fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3143 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3144 | __ JumpIfSmi(r0, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3145 | __ CompareObjectType(r0, r1, r1, JS_ARRAY_TYPE); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3146 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3147 | Split(eq, if_true, if_false, fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3148 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3149 | context()->Plug(if_true, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3150 | } |
| 3151 | |
| 3152 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3153 | void FullCodeGenerator::EmitIsRegExp(CallRuntime* expr) { |
| 3154 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3155 | ASSERT(args->length() == 1); |
| 3156 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3157 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3158 | |
| 3159 | Label materialize_true, materialize_false; |
| 3160 | Label* if_true = NULL; |
| 3161 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3162 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3163 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 3164 | &if_true, &if_false, &fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3165 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3166 | __ JumpIfSmi(r0, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3167 | __ CompareObjectType(r0, r1, r1, JS_REGEXP_TYPE); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3168 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3169 | Split(eq, if_true, if_false, fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3170 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3171 | context()->Plug(if_true, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3172 | } |
| 3173 | |
| 3174 | |
| 3175 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3176 | void FullCodeGenerator::EmitIsConstructCall(CallRuntime* expr) { |
| 3177 | ASSERT(expr->arguments()->length() == 0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3178 | |
| 3179 | Label materialize_true, materialize_false; |
| 3180 | Label* if_true = NULL; |
| 3181 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3182 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3183 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 3184 | &if_true, &if_false, &fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3185 | |
| 3186 | // Get the frame pointer for the calling frame. |
| 3187 | __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 3188 | |
| 3189 | // Skip the arguments adaptor frame if it exists. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3190 | __ ldr(r1, MemOperand(r2, StandardFrameConstants::kContextOffset)); |
| 3191 | __ cmp(r1, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 3192 | __ ldr(r2, MemOperand(r2, StandardFrameConstants::kCallerFPOffset), eq); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3193 | |
| 3194 | // Check the marker in the calling frame. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3195 | __ ldr(r1, MemOperand(r2, StandardFrameConstants::kMarkerOffset)); |
| 3196 | __ cmp(r1, Operand(Smi::FromInt(StackFrame::CONSTRUCT))); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3197 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3198 | Split(eq, if_true, if_false, fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3199 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3200 | context()->Plug(if_true, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3201 | } |
| 3202 | |
| 3203 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3204 | void FullCodeGenerator::EmitObjectEquals(CallRuntime* expr) { |
| 3205 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3206 | ASSERT(args->length() == 2); |
| 3207 | |
| 3208 | // Load the two objects into registers and perform the comparison. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3209 | VisitForStackValue(args->at(0)); |
| 3210 | VisitForAccumulatorValue(args->at(1)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3211 | |
| 3212 | Label materialize_true, materialize_false; |
| 3213 | Label* if_true = NULL; |
| 3214 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3215 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3216 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 3217 | &if_true, &if_false, &fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3218 | |
| 3219 | __ pop(r1); |
| 3220 | __ cmp(r0, r1); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3221 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 3222 | Split(eq, if_true, if_false, fall_through); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3223 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3224 | context()->Plug(if_true, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3225 | } |
| 3226 | |
| 3227 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3228 | void FullCodeGenerator::EmitArguments(CallRuntime* expr) { |
| 3229 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3230 | ASSERT(args->length() == 1); |
| 3231 | |
| 3232 | // ArgumentsAccessStub expects the key in edx and the formal |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3233 | // parameter count in r0. |
| 3234 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3235 | __ mov(r1, r0); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3236 | __ mov(r0, Operand(Smi::FromInt(info_->scope()->num_parameters()))); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3237 | ArgumentsAccessStub stub(ArgumentsAccessStub::READ_ELEMENT); |
| 3238 | __ CallStub(&stub); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3239 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3240 | } |
| 3241 | |
| 3242 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3243 | void FullCodeGenerator::EmitArgumentsLength(CallRuntime* expr) { |
| 3244 | ASSERT(expr->arguments()->length() == 0); |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 3245 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3246 | // Get the number of formal parameters. |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 3247 | __ mov(r0, Operand(Smi::FromInt(info_->scope()->num_parameters()))); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3248 | |
| 3249 | // Check if the calling frame is an arguments adaptor frame. |
| 3250 | __ ldr(r2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
| 3251 | __ ldr(r3, MemOperand(r2, StandardFrameConstants::kContextOffset)); |
| 3252 | __ cmp(r3, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3253 | |
| 3254 | // Arguments adaptor case: Read the arguments length from the |
| 3255 | // adaptor frame. |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 3256 | __ ldr(r0, MemOperand(r2, ArgumentsAdaptorFrameConstants::kLengthOffset), eq); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3257 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3258 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3259 | } |
| 3260 | |
| 3261 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3262 | void FullCodeGenerator::EmitClassOf(CallRuntime* expr) { |
| 3263 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3264 | ASSERT(args->length() == 1); |
| 3265 | Label done, null, function, non_function_constructor; |
| 3266 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3267 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3268 | |
| 3269 | // If the object is a smi, we return null. |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3270 | __ JumpIfSmi(r0, &null); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3271 | |
| 3272 | // Check that the object is a JS object but take special care of JS |
| 3273 | // functions to make sure they have 'Function' as their class. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3274 | // Assume that there are only two callable types, and one of them is at |
| 3275 | // either end of the type range for JS object types. Saves extra comparisons. |
| 3276 | STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 3277 | __ CompareObjectType(r0, r0, r1, FIRST_SPEC_OBJECT_TYPE); |
| 3278 | // Map is now in r0. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3279 | __ b(lt, &null); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3280 | STATIC_ASSERT(FIRST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 3281 | FIRST_SPEC_OBJECT_TYPE + 1); |
| 3282 | __ b(eq, &function); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3283 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3284 | __ cmp(r1, Operand(LAST_SPEC_OBJECT_TYPE)); |
| 3285 | STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == |
| 3286 | LAST_SPEC_OBJECT_TYPE - 1); |
| 3287 | __ b(eq, &function); |
| 3288 | // Assume that there is no larger type. |
| 3289 | STATIC_ASSERT(LAST_NONCALLABLE_SPEC_OBJECT_TYPE == LAST_TYPE - 1); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3290 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3291 | // Check if the constructor in the map is a JS function. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3292 | __ ldr(r0, FieldMemOperand(r0, Map::kConstructorOffset)); |
| 3293 | __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE); |
| 3294 | __ b(ne, &non_function_constructor); |
| 3295 | |
| 3296 | // r0 now contains the constructor function. Grab the |
| 3297 | // instance class name from there. |
| 3298 | __ ldr(r0, FieldMemOperand(r0, JSFunction::kSharedFunctionInfoOffset)); |
| 3299 | __ ldr(r0, FieldMemOperand(r0, SharedFunctionInfo::kInstanceClassNameOffset)); |
| 3300 | __ b(&done); |
| 3301 | |
| 3302 | // Functions have class 'Function'. |
| 3303 | __ bind(&function); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3304 | __ LoadRoot(r0, Heap::kfunction_class_stringRootIndex); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3305 | __ jmp(&done); |
| 3306 | |
| 3307 | // Objects with a non-function constructor have class 'Object'. |
| 3308 | __ bind(&non_function_constructor); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3309 | __ LoadRoot(r0, Heap::kObject_stringRootIndex); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3310 | __ jmp(&done); |
| 3311 | |
| 3312 | // Non-JS objects have class null. |
| 3313 | __ bind(&null); |
| 3314 | __ LoadRoot(r0, Heap::kNullValueRootIndex); |
| 3315 | |
| 3316 | // All done. |
| 3317 | __ bind(&done); |
| 3318 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3319 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3320 | } |
| 3321 | |
| 3322 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3323 | void FullCodeGenerator::EmitLog(CallRuntime* expr) { |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3324 | // Conditionally generate a log call. |
| 3325 | // Args: |
| 3326 | // 0 (literal string): The type of logging (corresponds to the flags). |
| 3327 | // This is used to determine whether or not to generate the log call. |
| 3328 | // 1 (string): Format string. Access the string at argument index 2 |
| 3329 | // with '%2s' (see Logger::LogRuntime for all the formats). |
| 3330 | // 2 (array): Arguments to the format string. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3331 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3332 | ASSERT_EQ(args->length(), 3); |
mstarzinger@chromium.org | e900018 | 2013-09-03 11:25:39 +0000 | [diff] [blame] | 3333 | if (CodeGenerator::ShouldGenerateLog(isolate(), args->at(0))) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3334 | VisitForStackValue(args->at(1)); |
| 3335 | VisitForStackValue(args->at(2)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3336 | __ CallRuntime(Runtime::kLog, 2); |
| 3337 | } |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 3338 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3339 | // Finally, we're expected to leave a value on the top of the stack. |
| 3340 | __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3341 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3342 | } |
| 3343 | |
| 3344 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3345 | void FullCodeGenerator::EmitSubString(CallRuntime* expr) { |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3346 | // Load the arguments on the stack and call the stub. |
| 3347 | SubStringStub stub; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3348 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3349 | ASSERT(args->length() == 3); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3350 | VisitForStackValue(args->at(0)); |
| 3351 | VisitForStackValue(args->at(1)); |
| 3352 | VisitForStackValue(args->at(2)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3353 | __ CallStub(&stub); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3354 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3355 | } |
| 3356 | |
| 3357 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3358 | void FullCodeGenerator::EmitRegExpExec(CallRuntime* expr) { |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3359 | // Load the arguments on the stack and call the stub. |
| 3360 | RegExpExecStub stub; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3361 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3362 | ASSERT(args->length() == 4); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3363 | VisitForStackValue(args->at(0)); |
| 3364 | VisitForStackValue(args->at(1)); |
| 3365 | VisitForStackValue(args->at(2)); |
| 3366 | VisitForStackValue(args->at(3)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3367 | __ CallStub(&stub); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3368 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3369 | } |
| 3370 | |
| 3371 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3372 | void FullCodeGenerator::EmitValueOf(CallRuntime* expr) { |
| 3373 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3374 | ASSERT(args->length() == 1); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3375 | VisitForAccumulatorValue(args->at(0)); // Load the object. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3376 | |
| 3377 | Label done; |
| 3378 | // If the object is a smi return the object. |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3379 | __ JumpIfSmi(r0, &done); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3380 | // If the object is not a value type, return the object. |
| 3381 | __ CompareObjectType(r0, r1, r1, JS_VALUE_TYPE); |
ulan@chromium.org | 9ca3017 | 2014-01-02 12:10:54 +0000 | [diff] [blame] | 3382 | __ ldr(r0, FieldMemOperand(r0, JSValue::kValueOffset), eq); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3383 | |
| 3384 | __ bind(&done); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3385 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3386 | } |
| 3387 | |
| 3388 | |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 3389 | void FullCodeGenerator::EmitDateField(CallRuntime* expr) { |
| 3390 | ZoneList<Expression*>* args = expr->arguments(); |
| 3391 | ASSERT(args->length() == 2); |
| 3392 | ASSERT_NE(NULL, args->at(1)->AsLiteral()); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 3393 | Smi* index = Smi::cast(*(args->at(1)->AsLiteral()->value())); |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 3394 | |
| 3395 | VisitForAccumulatorValue(args->at(0)); // Load the object. |
| 3396 | |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 3397 | Label runtime, done, not_date_object; |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 3398 | Register object = r0; |
| 3399 | Register result = r0; |
| 3400 | Register scratch0 = r9; |
| 3401 | Register scratch1 = r1; |
| 3402 | |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 3403 | __ JumpIfSmi(object, ¬_date_object); |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 3404 | __ CompareObjectType(object, scratch1, scratch1, JS_DATE_TYPE); |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 3405 | __ b(ne, ¬_date_object); |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 3406 | |
| 3407 | if (index->value() == 0) { |
| 3408 | __ ldr(result, FieldMemOperand(object, JSDate::kValueOffset)); |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 3409 | __ jmp(&done); |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 3410 | } else { |
| 3411 | if (index->value() < JSDate::kFirstUncachedField) { |
| 3412 | ExternalReference stamp = ExternalReference::date_cache_stamp(isolate()); |
| 3413 | __ mov(scratch1, Operand(stamp)); |
| 3414 | __ ldr(scratch1, MemOperand(scratch1)); |
| 3415 | __ ldr(scratch0, FieldMemOperand(object, JSDate::kCacheStampOffset)); |
| 3416 | __ cmp(scratch1, scratch0); |
| 3417 | __ b(ne, &runtime); |
| 3418 | __ ldr(result, FieldMemOperand(object, JSDate::kValueOffset + |
| 3419 | kPointerSize * index->value())); |
| 3420 | __ jmp(&done); |
| 3421 | } |
| 3422 | __ bind(&runtime); |
| 3423 | __ PrepareCallCFunction(2, scratch1); |
| 3424 | __ mov(r1, Operand(index)); |
| 3425 | __ CallCFunction(ExternalReference::get_date_field_function(isolate()), 2); |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 3426 | __ jmp(&done); |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 3427 | } |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 3428 | |
| 3429 | __ bind(¬_date_object); |
| 3430 | __ CallRuntime(Runtime::kThrowNotDateError, 0); |
| 3431 | __ bind(&done); |
svenpanne@chromium.org | 4efbdb1 | 2012-03-12 08:18:42 +0000 | [diff] [blame] | 3432 | context()->Plug(r0); |
| 3433 | } |
| 3434 | |
| 3435 | |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 3436 | void FullCodeGenerator::EmitOneByteSeqStringSetChar(CallRuntime* expr) { |
| 3437 | ZoneList<Expression*>* args = expr->arguments(); |
| 3438 | ASSERT_EQ(3, args->length()); |
| 3439 | |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 3440 | Register string = r0; |
| 3441 | Register index = r1; |
| 3442 | Register value = r2; |
| 3443 | |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 3444 | VisitForStackValue(args->at(1)); // index |
| 3445 | VisitForStackValue(args->at(2)); // value |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 3446 | VisitForAccumulatorValue(args->at(0)); // string |
machenbach@chromium.org | 9af454f | 2013-11-20 09:25:57 +0000 | [diff] [blame] | 3447 | __ Pop(index, value); |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 3448 | |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 3449 | if (FLAG_debug_code) { |
machenbach@chromium.org | 9af454f | 2013-11-20 09:25:57 +0000 | [diff] [blame] | 3450 | __ SmiTst(value); |
| 3451 | __ ThrowIf(ne, kNonSmiValue); |
| 3452 | __ SmiTst(index); |
| 3453 | __ ThrowIf(ne, kNonSmiIndex); |
| 3454 | __ SmiUntag(index, index); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 3455 | static const uint32_t one_byte_seq_type = kSeqStringTag | kOneByteStringTag; |
machenbach@chromium.org | 9af454f | 2013-11-20 09:25:57 +0000 | [diff] [blame] | 3456 | __ EmitSeqStringSetCharCheck(string, index, value, one_byte_seq_type); |
| 3457 | __ SmiTag(index, index); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 3458 | } |
| 3459 | |
| 3460 | __ SmiUntag(value, value); |
| 3461 | __ add(ip, |
| 3462 | string, |
| 3463 | Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
| 3464 | __ strb(value, MemOperand(ip, index, LSR, kSmiTagSize)); |
| 3465 | context()->Plug(string); |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 3466 | } |
| 3467 | |
| 3468 | |
| 3469 | void FullCodeGenerator::EmitTwoByteSeqStringSetChar(CallRuntime* expr) { |
| 3470 | ZoneList<Expression*>* args = expr->arguments(); |
| 3471 | ASSERT_EQ(3, args->length()); |
| 3472 | |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 3473 | Register string = r0; |
| 3474 | Register index = r1; |
| 3475 | Register value = r2; |
| 3476 | |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 3477 | VisitForStackValue(args->at(1)); // index |
| 3478 | VisitForStackValue(args->at(2)); // value |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 3479 | VisitForAccumulatorValue(args->at(0)); // string |
machenbach@chromium.org | 9af454f | 2013-11-20 09:25:57 +0000 | [diff] [blame] | 3480 | __ Pop(index, value); |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 3481 | |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 3482 | if (FLAG_debug_code) { |
machenbach@chromium.org | 9af454f | 2013-11-20 09:25:57 +0000 | [diff] [blame] | 3483 | __ SmiTst(value); |
| 3484 | __ ThrowIf(ne, kNonSmiValue); |
| 3485 | __ SmiTst(index); |
| 3486 | __ ThrowIf(ne, kNonSmiIndex); |
| 3487 | __ SmiUntag(index, index); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 3488 | static const uint32_t two_byte_seq_type = kSeqStringTag | kTwoByteStringTag; |
machenbach@chromium.org | 9af454f | 2013-11-20 09:25:57 +0000 | [diff] [blame] | 3489 | __ EmitSeqStringSetCharCheck(string, index, value, two_byte_seq_type); |
| 3490 | __ SmiTag(index, index); |
svenpanne@chromium.org | a53e8e0 | 2013-05-24 12:35:50 +0000 | [diff] [blame] | 3491 | } |
| 3492 | |
| 3493 | __ SmiUntag(value, value); |
| 3494 | __ add(ip, |
| 3495 | string, |
| 3496 | Operand(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 3497 | STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
| 3498 | __ strh(value, MemOperand(ip, index)); |
| 3499 | context()->Plug(string); |
mstarzinger@chromium.org | 32280cf | 2012-12-06 17:32:37 +0000 | [diff] [blame] | 3500 | } |
| 3501 | |
| 3502 | |
| 3503 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3504 | void FullCodeGenerator::EmitMathPow(CallRuntime* expr) { |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3505 | // Load the arguments on the stack and call the runtime function. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3506 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3507 | ASSERT(args->length() == 2); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3508 | VisitForStackValue(args->at(0)); |
| 3509 | VisitForStackValue(args->at(1)); |
mstarzinger@chromium.org | e27d617 | 2013-04-17 11:51:44 +0000 | [diff] [blame] | 3510 | MathPowStub stub(MathPowStub::ON_STACK); |
| 3511 | __ CallStub(&stub); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3512 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3513 | } |
| 3514 | |
| 3515 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3516 | void FullCodeGenerator::EmitSetValueOf(CallRuntime* expr) { |
| 3517 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3518 | ASSERT(args->length() == 2); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3519 | VisitForStackValue(args->at(0)); // Load the object. |
| 3520 | VisitForAccumulatorValue(args->at(1)); // Load the value. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3521 | __ pop(r1); // r0 = value. r1 = object. |
| 3522 | |
| 3523 | Label done; |
| 3524 | // If the object is a smi, return the value. |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3525 | __ JumpIfSmi(r1, &done); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3526 | |
| 3527 | // If the object is not a value type, return the value. |
| 3528 | __ CompareObjectType(r1, r2, r2, JS_VALUE_TYPE); |
| 3529 | __ b(ne, &done); |
| 3530 | |
| 3531 | // Store the value. |
| 3532 | __ str(r0, FieldMemOperand(r1, JSValue::kValueOffset)); |
| 3533 | // Update the write barrier. Save the value as it will be |
| 3534 | // overwritten by the write barrier code and is needed afterward. |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 3535 | __ mov(r2, r0); |
| 3536 | __ RecordWriteField( |
| 3537 | r1, JSValue::kValueOffset, r2, r3, kLRHasBeenSaved, kDontSaveFPRegs); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3538 | |
| 3539 | __ bind(&done); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3540 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3541 | } |
| 3542 | |
| 3543 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3544 | void FullCodeGenerator::EmitNumberToString(CallRuntime* expr) { |
| 3545 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3546 | ASSERT_EQ(args->length(), 1); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 3547 | // Load the argument into r0 and call the stub. |
| 3548 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3549 | |
| 3550 | NumberToStringStub stub; |
| 3551 | __ CallStub(&stub); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3552 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3553 | } |
| 3554 | |
| 3555 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3556 | void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) { |
| 3557 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3558 | ASSERT(args->length() == 1); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3559 | VisitForAccumulatorValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3560 | |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3561 | Label done; |
| 3562 | StringCharFromCodeGenerator generator(r0, r1); |
| 3563 | generator.GenerateFast(masm_); |
| 3564 | __ jmp(&done); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3565 | |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3566 | NopRuntimeCallHelper call_helper; |
| 3567 | generator.GenerateSlow(masm_, call_helper); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3568 | |
| 3569 | __ bind(&done); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3570 | context()->Plug(r1); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3571 | } |
| 3572 | |
| 3573 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3574 | void FullCodeGenerator::EmitStringCharCodeAt(CallRuntime* expr) { |
| 3575 | ZoneList<Expression*>* args = expr->arguments(); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3576 | ASSERT(args->length() == 2); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3577 | VisitForStackValue(args->at(0)); |
| 3578 | VisitForAccumulatorValue(args->at(1)); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3579 | |
| 3580 | Register object = r1; |
| 3581 | Register index = r0; |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3582 | Register result = r3; |
| 3583 | |
| 3584 | __ pop(object); |
| 3585 | |
| 3586 | Label need_conversion; |
| 3587 | Label index_out_of_range; |
| 3588 | Label done; |
| 3589 | StringCharCodeAtGenerator generator(object, |
| 3590 | index, |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3591 | result, |
| 3592 | &need_conversion, |
| 3593 | &need_conversion, |
| 3594 | &index_out_of_range, |
| 3595 | STRING_INDEX_IS_NUMBER); |
| 3596 | generator.GenerateFast(masm_); |
| 3597 | __ jmp(&done); |
| 3598 | |
| 3599 | __ bind(&index_out_of_range); |
| 3600 | // When the index is out of range, the spec requires us to return |
| 3601 | // NaN. |
| 3602 | __ LoadRoot(result, Heap::kNanValueRootIndex); |
| 3603 | __ jmp(&done); |
| 3604 | |
| 3605 | __ bind(&need_conversion); |
| 3606 | // Load the undefined value into the result register, which will |
| 3607 | // trigger conversion. |
| 3608 | __ LoadRoot(result, Heap::kUndefinedValueRootIndex); |
| 3609 | __ jmp(&done); |
| 3610 | |
| 3611 | NopRuntimeCallHelper call_helper; |
| 3612 | generator.GenerateSlow(masm_, call_helper); |
| 3613 | |
| 3614 | __ bind(&done); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3615 | context()->Plug(result); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3616 | } |
| 3617 | |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3618 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3619 | void FullCodeGenerator::EmitStringCharAt(CallRuntime* expr) { |
| 3620 | ZoneList<Expression*>* args = expr->arguments(); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3621 | ASSERT(args->length() == 2); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3622 | VisitForStackValue(args->at(0)); |
| 3623 | VisitForAccumulatorValue(args->at(1)); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3624 | |
| 3625 | Register object = r1; |
| 3626 | Register index = r0; |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 3627 | Register scratch = r3; |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3628 | Register result = r0; |
| 3629 | |
| 3630 | __ pop(object); |
| 3631 | |
| 3632 | Label need_conversion; |
| 3633 | Label index_out_of_range; |
| 3634 | Label done; |
| 3635 | StringCharAtGenerator generator(object, |
| 3636 | index, |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 3637 | scratch, |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3638 | result, |
| 3639 | &need_conversion, |
| 3640 | &need_conversion, |
| 3641 | &index_out_of_range, |
| 3642 | STRING_INDEX_IS_NUMBER); |
| 3643 | generator.GenerateFast(masm_); |
| 3644 | __ jmp(&done); |
| 3645 | |
| 3646 | __ bind(&index_out_of_range); |
| 3647 | // When the index is out of range, the spec requires us to return |
| 3648 | // the empty string. |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3649 | __ LoadRoot(result, Heap::kempty_stringRootIndex); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3650 | __ jmp(&done); |
| 3651 | |
| 3652 | __ bind(&need_conversion); |
| 3653 | // Move smi zero into the result register, which will trigger |
| 3654 | // conversion. |
| 3655 | __ mov(result, Operand(Smi::FromInt(0))); |
| 3656 | __ jmp(&done); |
| 3657 | |
| 3658 | NopRuntimeCallHelper call_helper; |
| 3659 | generator.GenerateSlow(masm_, call_helper); |
| 3660 | |
| 3661 | __ bind(&done); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3662 | context()->Plug(result); |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 3663 | } |
| 3664 | |
| 3665 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3666 | void FullCodeGenerator::EmitStringAdd(CallRuntime* expr) { |
| 3667 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3668 | ASSERT_EQ(2, args->length()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3669 | |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 3670 | if (FLAG_new_string_add) { |
| 3671 | VisitForStackValue(args->at(0)); |
| 3672 | VisitForAccumulatorValue(args->at(1)); |
| 3673 | |
| 3674 | __ pop(r1); |
| 3675 | NewStringAddStub stub(STRING_ADD_CHECK_BOTH, NOT_TENURED); |
| 3676 | __ CallStub(&stub); |
| 3677 | } else { |
| 3678 | VisitForStackValue(args->at(0)); |
| 3679 | VisitForStackValue(args->at(1)); |
| 3680 | |
| 3681 | StringAddStub stub(STRING_ADD_CHECK_BOTH); |
| 3682 | __ CallStub(&stub); |
| 3683 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3684 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3685 | } |
| 3686 | |
| 3687 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3688 | void FullCodeGenerator::EmitStringCompare(CallRuntime* expr) { |
| 3689 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3690 | ASSERT_EQ(2, args->length()); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3691 | VisitForStackValue(args->at(0)); |
| 3692 | VisitForStackValue(args->at(1)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3693 | |
| 3694 | StringCompareStub stub; |
| 3695 | __ CallStub(&stub); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3696 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3697 | } |
| 3698 | |
| 3699 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3700 | void FullCodeGenerator::EmitMathLog(CallRuntime* expr) { |
hpayer@chromium.org | 4f99be9 | 2013-12-18 16:23:55 +0000 | [diff] [blame] | 3701 | // Load the argument on the stack and call the runtime function. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3702 | ZoneList<Expression*>* args = expr->arguments(); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 3703 | ASSERT(args->length() == 1); |
| 3704 | VisitForStackValue(args->at(0)); |
hpayer@chromium.org | 4f99be9 | 2013-12-18 16:23:55 +0000 | [diff] [blame] | 3705 | __ CallRuntime(Runtime::kMath_log, 1); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3706 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3707 | } |
| 3708 | |
| 3709 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3710 | void FullCodeGenerator::EmitMathSqrt(CallRuntime* expr) { |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3711 | // Load the argument on the stack and call the runtime function. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3712 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3713 | ASSERT(args->length() == 1); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3714 | VisitForStackValue(args->at(0)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3715 | __ CallRuntime(Runtime::kMath_sqrt, 1); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3716 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3717 | } |
| 3718 | |
| 3719 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3720 | void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) { |
| 3721 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3722 | ASSERT(args->length() >= 2); |
| 3723 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 3724 | int arg_count = args->length() - 2; // 2 ~ receiver and function. |
| 3725 | for (int i = 0; i < arg_count + 1; i++) { |
| 3726 | VisitForStackValue(args->at(i)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3727 | } |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 3728 | VisitForAccumulatorValue(args->last()); // Function. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3729 | |
verwaest@chromium.org | de64f72 | 2012-08-16 15:44:54 +0000 | [diff] [blame] | 3730 | Label runtime, done; |
| 3731 | // Check for non-function argument (including proxy). |
| 3732 | __ JumpIfSmi(r0, &runtime); |
| 3733 | __ CompareObjectType(r0, r1, r1, JS_FUNCTION_TYPE); |
| 3734 | __ b(ne, &runtime); |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 3735 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 3736 | // InvokeFunction requires the function in r1. Move it in there. |
| 3737 | __ mov(r1, result_register()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3738 | ParameterCount count(arg_count); |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 3739 | __ InvokeFunction(r1, count, CALL_FUNCTION, |
| 3740 | NullCallWrapper(), CALL_AS_METHOD); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3741 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 3742 | __ jmp(&done); |
| 3743 | |
verwaest@chromium.org | de64f72 | 2012-08-16 15:44:54 +0000 | [diff] [blame] | 3744 | __ bind(&runtime); |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 3745 | __ push(r0); |
| 3746 | __ CallRuntime(Runtime::kCall, args->length()); |
| 3747 | __ bind(&done); |
| 3748 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3749 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3750 | } |
| 3751 | |
| 3752 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3753 | void FullCodeGenerator::EmitRegExpConstructResult(CallRuntime* expr) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3754 | RegExpConstructResultStub stub; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3755 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3756 | ASSERT(args->length() == 3); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3757 | VisitForStackValue(args->at(0)); |
| 3758 | VisitForStackValue(args->at(1)); |
| 3759 | VisitForStackValue(args->at(2)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3760 | __ CallStub(&stub); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3761 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3762 | } |
| 3763 | |
| 3764 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3765 | void FullCodeGenerator::EmitGetFromCache(CallRuntime* expr) { |
| 3766 | ZoneList<Expression*>* args = expr->arguments(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3767 | ASSERT_EQ(2, args->length()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3768 | ASSERT_NE(NULL, args->at(0)->AsLiteral()); |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 3769 | int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->value()))->value(); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3770 | |
| 3771 | Handle<FixedArray> jsfunction_result_caches( |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 3772 | isolate()->native_context()->jsfunction_result_caches()); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3773 | if (jsfunction_result_caches->length() <= cache_id) { |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 3774 | __ Abort(kAttemptToUseUndefinedCache); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3775 | __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3776 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3777 | return; |
| 3778 | } |
| 3779 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3780 | VisitForAccumulatorValue(args->at(1)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3781 | |
| 3782 | Register key = r0; |
| 3783 | Register cache = r1; |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 3784 | __ ldr(cache, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); |
| 3785 | __ ldr(cache, FieldMemOperand(cache, GlobalObject::kNativeContextOffset)); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 3786 | __ ldr(cache, ContextOperand(cache, Context::JSFUNCTION_RESULT_CACHES_INDEX)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3787 | __ ldr(cache, |
| 3788 | FieldMemOperand(cache, FixedArray::OffsetOfElementAt(cache_id))); |
| 3789 | |
| 3790 | |
| 3791 | Label done, not_found; |
| 3792 | // tmp now holds finger offset as a smi. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3793 | __ ldr(r2, FieldMemOperand(cache, JSFunctionResultCache::kFingerOffset)); |
| 3794 | // r2 now holds finger offset as a smi. |
| 3795 | __ add(r3, cache, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 3796 | // r3 now points to the start of fixed array elements. |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 3797 | __ ldr(r2, MemOperand::PointerAddressFromSmiKey(r3, r2, PreIndex)); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3798 | // Note side effect of PreIndex: r3 now points to the key of the pair. |
| 3799 | __ cmp(key, r2); |
| 3800 | __ b(ne, ¬_found); |
| 3801 | |
| 3802 | __ ldr(r0, MemOperand(r3, kPointerSize)); |
| 3803 | __ b(&done); |
| 3804 | |
| 3805 | __ bind(¬_found); |
| 3806 | // Call runtime to perform the lookup. |
| 3807 | __ Push(cache, key); |
| 3808 | __ CallRuntime(Runtime::kGetFromCache, 2); |
| 3809 | |
| 3810 | __ bind(&done); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3811 | context()->Plug(r0); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 3812 | } |
| 3813 | |
| 3814 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3815 | void FullCodeGenerator::EmitIsRegExpEquivalent(CallRuntime* expr) { |
| 3816 | ZoneList<Expression*>* args = expr->arguments(); |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 3817 | ASSERT_EQ(2, args->length()); |
| 3818 | |
| 3819 | Register right = r0; |
| 3820 | Register left = r1; |
| 3821 | Register tmp = r2; |
| 3822 | Register tmp2 = r3; |
| 3823 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3824 | VisitForStackValue(args->at(0)); |
| 3825 | VisitForAccumulatorValue(args->at(1)); |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 3826 | __ pop(left); |
| 3827 | |
| 3828 | Label done, fail, ok; |
| 3829 | __ cmp(left, Operand(right)); |
| 3830 | __ b(eq, &ok); |
| 3831 | // Fail if either is a non-HeapObject. |
| 3832 | __ and_(tmp, left, Operand(right)); |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 3833 | __ JumpIfSmi(tmp, &fail); |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 3834 | __ ldr(tmp, FieldMemOperand(left, HeapObject::kMapOffset)); |
| 3835 | __ ldrb(tmp2, FieldMemOperand(tmp, Map::kInstanceTypeOffset)); |
| 3836 | __ cmp(tmp2, Operand(JS_REGEXP_TYPE)); |
| 3837 | __ b(ne, &fail); |
| 3838 | __ ldr(tmp2, FieldMemOperand(right, HeapObject::kMapOffset)); |
| 3839 | __ cmp(tmp, Operand(tmp2)); |
| 3840 | __ b(ne, &fail); |
| 3841 | __ ldr(tmp, FieldMemOperand(left, JSRegExp::kDataOffset)); |
| 3842 | __ ldr(tmp2, FieldMemOperand(right, JSRegExp::kDataOffset)); |
| 3843 | __ cmp(tmp, tmp2); |
| 3844 | __ b(eq, &ok); |
| 3845 | __ bind(&fail); |
| 3846 | __ LoadRoot(r0, Heap::kFalseValueRootIndex); |
| 3847 | __ jmp(&done); |
| 3848 | __ bind(&ok); |
| 3849 | __ LoadRoot(r0, Heap::kTrueValueRootIndex); |
| 3850 | __ bind(&done); |
| 3851 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3852 | context()->Plug(r0); |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 3853 | } |
| 3854 | |
| 3855 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3856 | void FullCodeGenerator::EmitHasCachedArrayIndex(CallRuntime* expr) { |
| 3857 | ZoneList<Expression*>* args = expr->arguments(); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3858 | VisitForAccumulatorValue(args->at(0)); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 3859 | |
| 3860 | Label materialize_true, materialize_false; |
| 3861 | Label* if_true = NULL; |
| 3862 | Label* if_false = NULL; |
| 3863 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3864 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 3865 | &if_true, &if_false, &fall_through); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 3866 | |
| 3867 | __ ldr(r0, FieldMemOperand(r0, String::kHashFieldOffset)); |
| 3868 | __ tst(r0, Operand(String::kContainsCachedArrayIndexMask)); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3869 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3870 | Split(eq, if_true, if_false, fall_through); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 3871 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3872 | context()->Plug(if_true, if_false); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 3873 | } |
| 3874 | |
| 3875 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3876 | void FullCodeGenerator::EmitGetCachedArrayIndex(CallRuntime* expr) { |
| 3877 | ZoneList<Expression*>* args = expr->arguments(); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 3878 | ASSERT(args->length() == 1); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3879 | VisitForAccumulatorValue(args->at(0)); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 3880 | |
svenpanne@chromium.org | c859c4f | 2012-10-15 11:51:39 +0000 | [diff] [blame] | 3881 | __ AssertString(r0); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 3882 | |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 3883 | __ ldr(r0, FieldMemOperand(r0, String::kHashFieldOffset)); |
| 3884 | __ IndexFromHash(r0, r0); |
vegorov@chromium.org | 5d6c1f5 | 2011-02-28 13:13:38 +0000 | [diff] [blame] | 3885 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 3886 | context()->Plug(r0); |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 3887 | } |
| 3888 | |
| 3889 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3890 | void FullCodeGenerator::EmitFastAsciiArrayJoin(CallRuntime* expr) { |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 3891 | Label bailout, done, one_char_separator, long_separator, non_trivial_array, |
| 3892 | not_size_one_array, loop, empty_separator_loop, one_char_separator_loop, |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3893 | one_char_separator_loop_entry, long_separator_loop; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 3894 | ZoneList<Expression*>* args = expr->arguments(); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3895 | ASSERT(args->length() == 2); |
| 3896 | VisitForStackValue(args->at(1)); |
| 3897 | VisitForAccumulatorValue(args->at(0)); |
| 3898 | |
| 3899 | // All aliases of the same register have disjoint lifetimes. |
| 3900 | Register array = r0; |
| 3901 | Register elements = no_reg; // Will be r0. |
| 3902 | Register result = no_reg; // Will be r0. |
| 3903 | Register separator = r1; |
| 3904 | Register array_length = r2; |
| 3905 | Register result_pos = no_reg; // Will be r2 |
| 3906 | Register string_length = r3; |
| 3907 | Register string = r4; |
| 3908 | Register element = r5; |
| 3909 | Register elements_end = r6; |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 3910 | Register scratch = r9; |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3911 | |
| 3912 | // Separator operand is on the stack. |
| 3913 | __ pop(separator); |
| 3914 | |
| 3915 | // Check that the array is a JSArray. |
| 3916 | __ JumpIfSmi(array, &bailout); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 3917 | __ CompareObjectType(array, scratch, array_length, JS_ARRAY_TYPE); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3918 | __ b(ne, &bailout); |
| 3919 | |
| 3920 | // Check that the array has fast elements. |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 3921 | __ CheckFastElements(scratch, array_length, &bailout); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3922 | |
| 3923 | // If the array has length zero, return the empty string. |
| 3924 | __ ldr(array_length, FieldMemOperand(array, JSArray::kLengthOffset)); |
| 3925 | __ SmiUntag(array_length, SetCC); |
| 3926 | __ b(ne, &non_trivial_array); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 3927 | __ LoadRoot(r0, Heap::kempty_stringRootIndex); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3928 | __ b(&done); |
| 3929 | |
| 3930 | __ bind(&non_trivial_array); |
| 3931 | |
| 3932 | // Get the FixedArray containing array's elements. |
| 3933 | elements = array; |
| 3934 | __ ldr(elements, FieldMemOperand(array, JSArray::kElementsOffset)); |
| 3935 | array = no_reg; // End of array's live range. |
| 3936 | |
| 3937 | // Check that all array elements are sequential ASCII strings, and |
| 3938 | // accumulate the sum of their lengths, as a smi-encoded value. |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 3939 | __ mov(string_length, Operand::Zero()); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3940 | __ add(element, |
| 3941 | elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 3942 | __ add(elements_end, element, Operand(array_length, LSL, kPointerSizeLog2)); |
| 3943 | // Loop condition: while (element < elements_end). |
| 3944 | // Live values in registers: |
| 3945 | // elements: Fixed array of strings. |
| 3946 | // array_length: Length of the fixed array of strings (not smi) |
| 3947 | // separator: Separator string |
| 3948 | // string_length: Accumulated sum of string lengths (smi). |
| 3949 | // element: Current array element. |
| 3950 | // elements_end: Array end. |
jkummerow@chromium.org | 000f7fb | 2012-08-01 11:14:42 +0000 | [diff] [blame] | 3951 | if (generate_debug_code_) { |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 3952 | __ cmp(array_length, Operand::Zero()); |
danno@chromium.org | 5940060 | 2013-08-13 17:09:37 +0000 | [diff] [blame] | 3953 | __ Assert(gt, kNoEmptyArraysHereInEmitFastAsciiArrayJoin); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3954 | } |
| 3955 | __ bind(&loop); |
| 3956 | __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); |
| 3957 | __ JumpIfSmi(string, &bailout); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 3958 | __ ldr(scratch, FieldMemOperand(string, HeapObject::kMapOffset)); |
| 3959 | __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); |
| 3960 | __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch, &bailout); |
| 3961 | __ ldr(scratch, FieldMemOperand(string, SeqOneByteString::kLengthOffset)); |
| 3962 | __ add(string_length, string_length, Operand(scratch), SetCC); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3963 | __ b(vs, &bailout); |
| 3964 | __ cmp(element, elements_end); |
| 3965 | __ b(lt, &loop); |
| 3966 | |
| 3967 | // If array_length is 1, return elements[0], a string. |
| 3968 | __ cmp(array_length, Operand(1)); |
| 3969 | __ b(ne, ¬_size_one_array); |
| 3970 | __ ldr(r0, FieldMemOperand(elements, FixedArray::kHeaderSize)); |
| 3971 | __ b(&done); |
| 3972 | |
| 3973 | __ bind(¬_size_one_array); |
| 3974 | |
| 3975 | // Live values in registers: |
| 3976 | // separator: Separator string |
| 3977 | // array_length: Length of the array. |
| 3978 | // string_length: Sum of string lengths (smi). |
| 3979 | // elements: FixedArray of strings. |
| 3980 | |
| 3981 | // Check that the separator is a flat ASCII string. |
| 3982 | __ JumpIfSmi(separator, &bailout); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 3983 | __ ldr(scratch, FieldMemOperand(separator, HeapObject::kMapOffset)); |
| 3984 | __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); |
| 3985 | __ JumpIfInstanceTypeIsNotSequentialAscii(scratch, scratch, &bailout); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3986 | |
| 3987 | // Add (separator length times array_length) - separator length to the |
| 3988 | // string_length to get the length of the result string. array_length is not |
| 3989 | // smi but the other values are, so the result is a smi |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 3990 | __ ldr(scratch, FieldMemOperand(separator, SeqOneByteString::kLengthOffset)); |
| 3991 | __ sub(string_length, string_length, Operand(scratch)); |
| 3992 | __ smull(scratch, ip, array_length, scratch); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3993 | // Check for smi overflow. No overflow if higher 33 bits of 64-bit result are |
| 3994 | // zero. |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 3995 | __ cmp(ip, Operand::Zero()); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3996 | __ b(ne, &bailout); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 3997 | __ tst(scratch, Operand(0x80000000)); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 3998 | __ b(ne, &bailout); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 3999 | __ add(string_length, string_length, Operand(scratch), SetCC); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4000 | __ b(vs, &bailout); |
| 4001 | __ SmiUntag(string_length); |
| 4002 | |
| 4003 | // Get first element in the array to free up the elements register to be used |
| 4004 | // for the result. |
| 4005 | __ add(element, |
| 4006 | elements, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); |
| 4007 | result = elements; // End of live range for elements. |
| 4008 | elements = no_reg; |
| 4009 | // Live values in registers: |
| 4010 | // element: First array element |
| 4011 | // separator: Separator string |
| 4012 | // string_length: Length of result string (not smi) |
| 4013 | // array_length: Length of the array. |
| 4014 | __ AllocateAsciiString(result, |
| 4015 | string_length, |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 4016 | scratch, |
| 4017 | string, // used as scratch |
| 4018 | elements_end, // used as scratch |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4019 | &bailout); |
| 4020 | // Prepare for looping. Set up elements_end to end of the array. Set |
| 4021 | // result_pos to the position of the result where to write the first |
| 4022 | // character. |
| 4023 | __ add(elements_end, element, Operand(array_length, LSL, kPointerSizeLog2)); |
| 4024 | result_pos = array_length; // End of live range for array_length. |
| 4025 | array_length = no_reg; |
| 4026 | __ add(result_pos, |
| 4027 | result, |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4028 | Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4029 | |
| 4030 | // Check the length of the separator. |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 4031 | __ ldr(scratch, FieldMemOperand(separator, SeqOneByteString::kLengthOffset)); |
| 4032 | __ cmp(scratch, Operand(Smi::FromInt(1))); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4033 | __ b(eq, &one_char_separator); |
| 4034 | __ b(gt, &long_separator); |
| 4035 | |
| 4036 | // Empty separator case |
| 4037 | __ bind(&empty_separator_loop); |
| 4038 | // Live values in registers: |
| 4039 | // result_pos: the position to which we are currently copying characters. |
| 4040 | // element: Current array element. |
| 4041 | // elements_end: Array end. |
| 4042 | |
| 4043 | // Copy next array element to the result. |
| 4044 | __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); |
| 4045 | __ ldr(string_length, FieldMemOperand(string, String::kLengthOffset)); |
| 4046 | __ SmiUntag(string_length); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4047 | __ add(string, |
| 4048 | string, |
| 4049 | Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 4050 | __ CopyBytes(string, result_pos, string_length, scratch); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4051 | __ cmp(element, elements_end); |
| 4052 | __ b(lt, &empty_separator_loop); // End while (element < elements_end). |
| 4053 | ASSERT(result.is(r0)); |
| 4054 | __ b(&done); |
| 4055 | |
| 4056 | // One-character separator case |
| 4057 | __ bind(&one_char_separator); |
ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 4058 | // Replace separator with its ASCII character value. |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4059 | __ ldrb(separator, FieldMemOperand(separator, SeqOneByteString::kHeaderSize)); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4060 | // Jump into the loop after the code that copies the separator, so the first |
| 4061 | // element is not preceded by a separator |
| 4062 | __ jmp(&one_char_separator_loop_entry); |
| 4063 | |
| 4064 | __ bind(&one_char_separator_loop); |
| 4065 | // Live values in registers: |
| 4066 | // result_pos: the position to which we are currently copying characters. |
| 4067 | // element: Current array element. |
| 4068 | // elements_end: Array end. |
ulan@chromium.org | 2efb900 | 2012-01-19 15:36:35 +0000 | [diff] [blame] | 4069 | // separator: Single separator ASCII char (in lower byte). |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4070 | |
| 4071 | // Copy the separator character to the result. |
| 4072 | __ strb(separator, MemOperand(result_pos, 1, PostIndex)); |
| 4073 | |
| 4074 | // Copy next array element to the result. |
| 4075 | __ bind(&one_char_separator_loop_entry); |
| 4076 | __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); |
| 4077 | __ ldr(string_length, FieldMemOperand(string, String::kLengthOffset)); |
| 4078 | __ SmiUntag(string_length); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4079 | __ add(string, |
| 4080 | string, |
| 4081 | Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 4082 | __ CopyBytes(string, result_pos, string_length, scratch); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4083 | __ cmp(element, elements_end); |
| 4084 | __ b(lt, &one_char_separator_loop); // End while (element < elements_end). |
| 4085 | ASSERT(result.is(r0)); |
| 4086 | __ b(&done); |
| 4087 | |
| 4088 | // Long separator case (separator is more than one character). Entry is at the |
| 4089 | // label long_separator below. |
| 4090 | __ bind(&long_separator_loop); |
| 4091 | // Live values in registers: |
| 4092 | // result_pos: the position to which we are currently copying characters. |
| 4093 | // element: Current array element. |
| 4094 | // elements_end: Array end. |
| 4095 | // separator: Separator string. |
| 4096 | |
| 4097 | // Copy the separator to the result. |
| 4098 | __ ldr(string_length, FieldMemOperand(separator, String::kLengthOffset)); |
| 4099 | __ SmiUntag(string_length); |
| 4100 | __ add(string, |
| 4101 | separator, |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4102 | Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 4103 | __ CopyBytes(string, result_pos, string_length, scratch); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4104 | |
| 4105 | __ bind(&long_separator); |
| 4106 | __ ldr(string, MemOperand(element, kPointerSize, PostIndex)); |
| 4107 | __ ldr(string_length, FieldMemOperand(string, String::kLengthOffset)); |
| 4108 | __ SmiUntag(string_length); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4109 | __ add(string, |
| 4110 | string, |
| 4111 | Operand(SeqOneByteString::kHeaderSize - kHeapObjectTag)); |
machenbach@chromium.org | 3d079fe | 2013-09-25 08:19:55 +0000 | [diff] [blame] | 4112 | __ CopyBytes(string, result_pos, string_length, scratch); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4113 | __ cmp(element, elements_end); |
| 4114 | __ b(lt, &long_separator_loop); // End while (element < elements_end). |
| 4115 | ASSERT(result.is(r0)); |
| 4116 | __ b(&done); |
| 4117 | |
| 4118 | __ bind(&bailout); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 4119 | __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 4120 | __ bind(&done); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 4121 | context()->Plug(r0); |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 4122 | } |
| 4123 | |
| 4124 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4125 | void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 4126 | Handle<String> name = expr->name(); |
| 4127 | if (name->length() > 0 && name->Get(0) == '_') { |
| 4128 | Comment cmnt(masm_, "[ InlineRuntimeCall"); |
| 4129 | EmitInlineRuntimeCall(expr); |
| 4130 | return; |
| 4131 | } |
| 4132 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4133 | Comment cmnt(masm_, "[ CallRuntime"); |
| 4134 | ZoneList<Expression*>* args = expr->arguments(); |
| 4135 | |
| 4136 | if (expr->is_jsruntime()) { |
| 4137 | // Prepare for calling JS runtime function. |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 4138 | __ ldr(r0, GlobalObjectOperand()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4139 | __ ldr(r0, FieldMemOperand(r0, GlobalObject::kBuiltinsOffset)); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 4140 | __ push(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4141 | } |
| 4142 | |
| 4143 | // Push the arguments ("left-to-right"). |
| 4144 | int arg_count = args->length(); |
| 4145 | for (int i = 0; i < arg_count; i++) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4146 | VisitForStackValue(args->at(i)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4147 | } |
| 4148 | |
| 4149 | if (expr->is_jsruntime()) { |
| 4150 | // Call the JS runtime function. |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 4151 | __ mov(r2, Operand(expr->name())); |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 4152 | RelocInfo::Mode mode = RelocInfo::CODE_TARGET; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 4153 | Handle<Code> ic = |
lrn@chromium.org | 34e6078 | 2011-09-15 07:25:40 +0000 | [diff] [blame] | 4154 | isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4155 | CallIC(ic, mode, expr->CallRuntimeFeedbackId()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4156 | // Restore context register. |
| 4157 | __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4158 | } else { |
| 4159 | // Call the C runtime function. |
| 4160 | __ CallRuntime(expr->function(), arg_count); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4161 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4162 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4163 | } |
| 4164 | |
| 4165 | |
| 4166 | void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) { |
| 4167 | switch (expr->op()) { |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 4168 | case Token::DELETE: { |
| 4169 | Comment cmnt(masm_, "[ UnaryOperation (DELETE)"); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4170 | Property* property = expr->expression()->AsProperty(); |
| 4171 | VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4172 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4173 | if (property != NULL) { |
| 4174 | VisitForStackValue(property->obj()); |
| 4175 | VisitForStackValue(property->key()); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 4176 | StrictModeFlag strict_mode_flag = (language_mode() == CLASSIC_MODE) |
| 4177 | ? kNonStrictMode : kStrictMode; |
| 4178 | __ mov(r1, Operand(Smi::FromInt(strict_mode_flag))); |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 4179 | __ push(r1); |
| 4180 | __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); |
| 4181 | context()->Plug(r0); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4182 | } else if (proxy != NULL) { |
| 4183 | Variable* var = proxy->var(); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4184 | // Delete of an unqualified identifier is disallowed in strict mode |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4185 | // but "delete this" is allowed. |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 4186 | ASSERT(language_mode() == CLASSIC_MODE || var->is_this()); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4187 | if (var->IsUnallocated()) { |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4188 | __ ldr(r2, GlobalObjectOperand()); |
| 4189 | __ mov(r1, Operand(var->name())); |
| 4190 | __ mov(r0, Operand(Smi::FromInt(kNonStrictMode))); |
| 4191 | __ Push(r2, r1, r0); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 4192 | __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4193 | context()->Plug(r0); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4194 | } else if (var->IsStackAllocated() || var->IsContextSlot()) { |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4195 | // Result of deleting non-global, non-dynamic variables is false. |
| 4196 | // The subexpression does not have side effects. |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4197 | context()->Plug(var->is_this()); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4198 | } else { |
| 4199 | // Non-global variable. Call the runtime to try to delete from the |
| 4200 | // context where the variable was introduced. |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 4201 | ASSERT(!context_register().is(r2)); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4202 | __ mov(r2, Operand(var->name())); |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 4203 | __ Push(context_register(), r2); |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4204 | __ CallRuntime(Runtime::kDeleteContextSlot, 2); |
| 4205 | context()->Plug(r0); |
| 4206 | } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4207 | } else { |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 4208 | // Result of deleting non-property, non-variable reference is true. |
| 4209 | // The subexpression may have side effects. |
| 4210 | VisitForEffect(expr->expression()); |
| 4211 | context()->Plug(true); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 4212 | } |
| 4213 | break; |
| 4214 | } |
| 4215 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4216 | case Token::VOID: { |
| 4217 | Comment cmnt(masm_, "[ UnaryOperation (VOID)"); |
| 4218 | VisitForEffect(expr->expression()); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4219 | context()->Plug(Heap::kUndefinedValueRootIndex); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4220 | break; |
| 4221 | } |
| 4222 | |
| 4223 | case Token::NOT: { |
| 4224 | Comment cmnt(masm_, "[ UnaryOperation (NOT)"); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4225 | if (context()->IsEffect()) { |
| 4226 | // Unary NOT has no side effects so it's only necessary to visit the |
| 4227 | // subexpression. Match the optimizing compiler by not branching. |
| 4228 | VisitForEffect(expr->expression()); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4229 | } else if (context()->IsTest()) { |
| 4230 | const TestContext* test = TestContext::cast(context()); |
| 4231 | // The labels are swapped for the recursive call. |
| 4232 | VisitForControl(expr->expression(), |
| 4233 | test->false_label(), |
| 4234 | test->true_label(), |
| 4235 | test->fall_through()); |
| 4236 | context()->Plug(test->true_label(), test->false_label()); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4237 | } else { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4238 | // We handle value contexts explicitly rather than simply visiting |
| 4239 | // for control and plugging the control flow into the context, |
| 4240 | // because we need to prepare a pair of extra administrative AST ids |
| 4241 | // for the optimizing compiler. |
| 4242 | ASSERT(context()->IsAccumulatorValue() || context()->IsStackValue()); |
| 4243 | Label materialize_true, materialize_false, done; |
| 4244 | VisitForControl(expr->expression(), |
| 4245 | &materialize_false, |
| 4246 | &materialize_true, |
| 4247 | &materialize_true); |
| 4248 | __ bind(&materialize_true); |
| 4249 | PrepareForBailoutForId(expr->MaterializeTrueId(), NO_REGISTERS); |
| 4250 | __ LoadRoot(r0, Heap::kTrueValueRootIndex); |
| 4251 | if (context()->IsStackValue()) __ push(r0); |
| 4252 | __ jmp(&done); |
| 4253 | __ bind(&materialize_false); |
| 4254 | PrepareForBailoutForId(expr->MaterializeFalseId(), NO_REGISTERS); |
| 4255 | __ LoadRoot(r0, Heap::kFalseValueRootIndex); |
| 4256 | if (context()->IsStackValue()) __ push(r0); |
| 4257 | __ bind(&done); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 4258 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4259 | break; |
| 4260 | } |
| 4261 | |
| 4262 | case Token::TYPEOF: { |
| 4263 | Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)"); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4264 | { StackValueContext context(this); |
| 4265 | VisitForTypeofValue(expr->expression()); |
| 4266 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4267 | __ CallRuntime(Runtime::kTypeof, 1); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4268 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4269 | break; |
| 4270 | } |
| 4271 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4272 | default: |
| 4273 | UNREACHABLE(); |
| 4274 | } |
| 4275 | } |
| 4276 | |
| 4277 | |
| 4278 | void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
| 4279 | Comment cmnt(masm_, "[ CountOperation"); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4280 | SetSourcePosition(expr->position()); |
| 4281 | |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 4282 | // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' |
| 4283 | // as the left-hand side. |
| 4284 | if (!expr->expression()->IsValidLeftHandSide()) { |
| 4285 | VisitForEffect(expr->expression()); |
| 4286 | return; |
| 4287 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4288 | |
| 4289 | // Expression can only be a property, a global or a (parameter or local) |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 4290 | // slot. |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4291 | enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; |
| 4292 | LhsKind assign_type = VARIABLE; |
| 4293 | Property* prop = expr->expression()->AsProperty(); |
| 4294 | // In case of a property we use the uninitialized expression context |
| 4295 | // of the key to detect a named property. |
| 4296 | if (prop != NULL) { |
| 4297 | assign_type = |
| 4298 | (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; |
| 4299 | } |
| 4300 | |
| 4301 | // Evaluate expression and get value. |
| 4302 | if (assign_type == VARIABLE) { |
| 4303 | ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4304 | AccumulatorValueContext context(this); |
whesse@chromium.org | 030d38e | 2011-07-13 13:23:34 +0000 | [diff] [blame] | 4305 | EmitVariableLoad(expr->expression()->AsVariableProxy()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4306 | } else { |
| 4307 | // Reserve space for result of postfix operation. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4308 | if (expr->is_postfix() && !context()->IsEffect()) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4309 | __ mov(ip, Operand(Smi::FromInt(0))); |
| 4310 | __ push(ip); |
| 4311 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4312 | if (assign_type == NAMED_PROPERTY) { |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 4313 | // Put the object both on the stack and in the accumulator. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4314 | VisitForAccumulatorValue(prop->obj()); |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 4315 | __ push(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4316 | EmitNamedPropertyLoad(prop); |
| 4317 | } else { |
whesse@chromium.org | 7b26015 | 2011-06-20 15:33:18 +0000 | [diff] [blame] | 4318 | VisitForStackValue(prop->obj()); |
| 4319 | VisitForAccumulatorValue(prop->key()); |
sgjesse@chromium.org | 720dc0b | 2010-05-10 09:25:39 +0000 | [diff] [blame] | 4320 | __ ldr(r1, MemOperand(sp, 0)); |
| 4321 | __ push(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4322 | EmitKeyedPropertyLoad(prop); |
| 4323 | } |
| 4324 | } |
| 4325 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4326 | // We need a second deoptimization point after loading the value |
| 4327 | // in case evaluating the property load my have a side effect. |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 4328 | if (assign_type == VARIABLE) { |
| 4329 | PrepareForBailout(expr->expression(), TOS_REG); |
| 4330 | } else { |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4331 | PrepareForBailoutForId(prop->LoadId(), TOS_REG); |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 4332 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4333 | |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 4334 | // Inline smi case if we are in a loop. |
| 4335 | Label stub_call, done; |
| 4336 | JumpPatchSite patch_site(masm_); |
| 4337 | |
| 4338 | int count_value = expr->op() == Token::INC ? 1 : -1; |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 4339 | if (ShouldInlineSmiCase(expr->op())) { |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 4340 | Label slow; |
| 4341 | patch_site.EmitJumpIfNotSmi(r0, &slow); |
| 4342 | |
| 4343 | // Save result for postfix expressions. |
| 4344 | if (expr->is_postfix()) { |
| 4345 | if (!context()->IsEffect()) { |
| 4346 | // Save the result on the stack. If we have a named or keyed property |
| 4347 | // we store the result under the receiver that is currently on top |
| 4348 | // of the stack. |
| 4349 | switch (assign_type) { |
| 4350 | case VARIABLE: |
| 4351 | __ push(r0); |
| 4352 | break; |
| 4353 | case NAMED_PROPERTY: |
| 4354 | __ str(r0, MemOperand(sp, kPointerSize)); |
| 4355 | break; |
| 4356 | case KEYED_PROPERTY: |
| 4357 | __ str(r0, MemOperand(sp, 2 * kPointerSize)); |
| 4358 | break; |
| 4359 | } |
| 4360 | } |
| 4361 | } |
| 4362 | |
| 4363 | __ add(r0, r0, Operand(Smi::FromInt(count_value)), SetCC); |
| 4364 | __ b(vc, &done); |
| 4365 | // Call stub. Undo operation first. |
| 4366 | __ sub(r0, r0, Operand(Smi::FromInt(count_value))); |
| 4367 | __ jmp(&stub_call); |
| 4368 | __ bind(&slow); |
jkummerow@chromium.org | ba72ec8 | 2013-07-22 09:21:20 +0000 | [diff] [blame] | 4369 | } |
whesse@chromium.org | 7a392b3 | 2011-01-31 11:30:36 +0000 | [diff] [blame] | 4370 | ToNumberStub convert_stub; |
| 4371 | __ CallStub(&convert_stub); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4372 | |
| 4373 | // Save result for postfix expressions. |
| 4374 | if (expr->is_postfix()) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4375 | if (!context()->IsEffect()) { |
| 4376 | // Save the result on the stack. If we have a named or keyed property |
| 4377 | // we store the result under the receiver that is currently on top |
| 4378 | // of the stack. |
| 4379 | switch (assign_type) { |
| 4380 | case VARIABLE: |
| 4381 | __ push(r0); |
| 4382 | break; |
| 4383 | case NAMED_PROPERTY: |
| 4384 | __ str(r0, MemOperand(sp, kPointerSize)); |
| 4385 | break; |
| 4386 | case KEYED_PROPERTY: |
| 4387 | __ str(r0, MemOperand(sp, 2 * kPointerSize)); |
| 4388 | break; |
| 4389 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4390 | } |
| 4391 | } |
| 4392 | |
| 4393 | |
machenbach@chromium.org | e8412be | 2013-11-08 10:23:52 +0000 | [diff] [blame] | 4394 | __ bind(&stub_call); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4395 | __ mov(r1, r0); |
| 4396 | __ mov(r0, Operand(Smi::FromInt(count_value))); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4397 | |
| 4398 | // Record position before stub call. |
| 4399 | SetSourcePosition(expr->position()); |
| 4400 | |
machenbach@chromium.org | ce9c514 | 2013-12-03 08:00:39 +0000 | [diff] [blame] | 4401 | BinaryOpICStub stub(Token::ADD, NO_OVERWRITE); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 4402 | CallIC(stub.GetCode(isolate()), |
| 4403 | RelocInfo::CODE_TARGET, |
| 4404 | expr->CountBinOpFeedbackId()); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4405 | patch_site.EmitPatchInfo(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4406 | __ bind(&done); |
| 4407 | |
| 4408 | // Store the value returned in r0. |
| 4409 | switch (assign_type) { |
| 4410 | case VARIABLE: |
| 4411 | if (expr->is_postfix()) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4412 | { EffectContext context(this); |
| 4413 | EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
| 4414 | Token::ASSIGN); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4415 | PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 4416 | context.Plug(r0); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4417 | } |
| 4418 | // For all contexts except EffectConstant We have the result on |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4419 | // top of the stack. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4420 | if (!context()->IsEffect()) { |
| 4421 | context()->PlugTOS(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4422 | } |
| 4423 | } else { |
| 4424 | EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4425 | Token::ASSIGN); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4426 | PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
| 4427 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4428 | } |
| 4429 | break; |
| 4430 | case NAMED_PROPERTY: { |
mstarzinger@chromium.org | 1510d58 | 2013-06-28 14:00:48 +0000 | [diff] [blame] | 4431 | __ mov(r2, Operand(prop->key()->AsLiteral()->value())); |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 4432 | __ pop(r1); |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 4433 | Handle<Code> ic = is_classic_mode() |
| 4434 | ? isolate()->builtins()->StoreIC_Initialize() |
| 4435 | : isolate()->builtins()->StoreIC_Initialize_Strict(); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4436 | CallIC(ic, RelocInfo::CODE_TARGET, expr->CountStoreFeedbackId()); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4437 | PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4438 | if (expr->is_postfix()) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4439 | if (!context()->IsEffect()) { |
| 4440 | context()->PlugTOS(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4441 | } |
| 4442 | } else { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4443 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4444 | } |
| 4445 | break; |
| 4446 | } |
| 4447 | case KEYED_PROPERTY: { |
verwaest@chromium.org | 057bd50 | 2013-11-06 12:03:29 +0000 | [diff] [blame] | 4448 | __ Pop(r2, r1); // r1 = key. r2 = receiver. |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 4449 | Handle<Code> ic = is_classic_mode() |
| 4450 | ? isolate()->builtins()->KeyedStoreIC_Initialize() |
| 4451 | : isolate()->builtins()->KeyedStoreIC_Initialize_Strict(); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4452 | CallIC(ic, RelocInfo::CODE_TARGET, expr->CountStoreFeedbackId()); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4453 | PrepareForBailoutForId(expr->AssignmentId(), TOS_REG); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4454 | if (expr->is_postfix()) { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4455 | if (!context()->IsEffect()) { |
| 4456 | context()->PlugTOS(); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4457 | } |
| 4458 | } else { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4459 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4460 | } |
| 4461 | break; |
| 4462 | } |
| 4463 | } |
| 4464 | } |
| 4465 | |
| 4466 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4467 | void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
| 4468 | ASSERT(!context()->IsEffect()); |
| 4469 | ASSERT(!context()->IsTest()); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4470 | VariableProxy* proxy = expr->AsVariableProxy(); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4471 | if (proxy != NULL && proxy->var()->IsUnallocated()) { |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4472 | Comment cmnt(masm_, "Global variable"); |
erik.corry@gmail.com | 4a6c327 | 2010-11-18 12:04:40 +0000 | [diff] [blame] | 4473 | __ ldr(r0, GlobalObjectOperand()); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4474 | __ mov(r2, Operand(proxy->name())); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 4475 | Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4476 | // Use a regular load, not a contextual load, to avoid a reference |
| 4477 | // error. |
danno@chromium.org | 88aa058 | 2012-03-23 15:11:57 +0000 | [diff] [blame] | 4478 | CallIC(ic); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4479 | PrepareForBailout(expr, TOS_REG); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4480 | context()->Plug(r0); |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4481 | } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 4482 | Label done, slow; |
| 4483 | |
| 4484 | // Generate code for loading from variables potentially shadowed |
| 4485 | // by eval-introduced variables. |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4486 | EmitDynamicLookupFastCase(proxy->var(), INSIDE_TYPEOF, &slow, &done); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 4487 | |
| 4488 | __ bind(&slow); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4489 | __ mov(r0, Operand(proxy->name())); |
| 4490 | __ Push(cp, r0); |
| 4491 | __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4492 | PrepareForBailout(expr, TOS_REG); |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 4493 | __ bind(&done); |
| 4494 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4495 | context()->Plug(r0); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4496 | } else { |
| 4497 | // This expression cannot throw a reference error at the top level. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4498 | VisitInDuplicateContext(expr); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4499 | } |
| 4500 | } |
| 4501 | |
| 4502 | |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 4503 | void FullCodeGenerator::EmitLiteralCompareTypeof(Expression* expr, |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4504 | Expression* sub_expr, |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4505 | Handle<String> check) { |
| 4506 | Label materialize_true, materialize_false; |
| 4507 | Label* if_true = NULL; |
| 4508 | Label* if_false = NULL; |
| 4509 | Label* fall_through = NULL; |
| 4510 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 4511 | &if_true, &if_false, &fall_through); |
| 4512 | |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4513 | { AccumulatorValueContext context(this); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4514 | VisitForTypeofValue(sub_expr); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4515 | } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4516 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4517 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 4518 | if (check->Equals(isolate()->heap()->number_string())) { |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4519 | __ JumpIfSmi(r0, if_true); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4520 | __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 4521 | __ LoadRoot(ip, Heap::kHeapNumberMapRootIndex); |
| 4522 | __ cmp(r0, ip); |
| 4523 | Split(eq, if_true, if_false, fall_through); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 4524 | } else if (check->Equals(isolate()->heap()->string_string())) { |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4525 | __ JumpIfSmi(r0, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4526 | // Check for undetectable objects => false. |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4527 | __ CompareObjectType(r0, r0, r1, FIRST_NONSTRING_TYPE); |
| 4528 | __ b(ge, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4529 | __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4530 | __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
| 4531 | Split(eq, if_true, if_false, fall_through); |
mstarzinger@chromium.org | f705b50 | 2013-04-04 11:38:09 +0000 | [diff] [blame] | 4532 | } else if (check->Equals(isolate()->heap()->symbol_string())) { |
| 4533 | __ JumpIfSmi(r0, if_false); |
| 4534 | __ CompareObjectType(r0, r0, r1, SYMBOL_TYPE); |
| 4535 | Split(eq, if_true, if_false, fall_through); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 4536 | } else if (check->Equals(isolate()->heap()->boolean_string())) { |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4537 | __ CompareRoot(r0, Heap::kTrueValueRootIndex); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 4538 | __ b(eq, if_true); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4539 | __ CompareRoot(r0, Heap::kFalseValueRootIndex); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4540 | Split(eq, if_true, if_false, fall_through); |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 4541 | } else if (FLAG_harmony_typeof && |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 4542 | check->Equals(isolate()->heap()->null_string())) { |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 4543 | __ CompareRoot(r0, Heap::kNullValueRootIndex); |
| 4544 | Split(eq, if_true, if_false, fall_through); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 4545 | } else if (check->Equals(isolate()->heap()->undefined_string())) { |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4546 | __ CompareRoot(r0, Heap::kUndefinedValueRootIndex); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 4547 | __ b(eq, if_true); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4548 | __ JumpIfSmi(r0, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4549 | // Check for undetectable objects => true. |
| 4550 | __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); |
| 4551 | __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4552 | __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
| 4553 | Split(ne, if_true, if_false, fall_through); |
| 4554 | |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 4555 | } else if (check->Equals(isolate()->heap()->function_string())) { |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4556 | __ JumpIfSmi(r0, if_false); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4557 | STATIC_ASSERT(NUM_OF_CALLABLE_SPEC_OBJECT_TYPES == 2); |
| 4558 | __ CompareObjectType(r0, r0, r1, JS_FUNCTION_TYPE); |
| 4559 | __ b(eq, if_true); |
| 4560 | __ cmp(r1, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 4561 | Split(eq, if_true, if_false, fall_through); |
yangguo@chromium.org | 4a9f655 | 2013-03-04 14:46:33 +0000 | [diff] [blame] | 4562 | } else if (check->Equals(isolate()->heap()->object_string())) { |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4563 | __ JumpIfSmi(r0, if_false); |
whesse@chromium.org | 4acdc2c | 2011-08-15 13:01:23 +0000 | [diff] [blame] | 4564 | if (!FLAG_harmony_typeof) { |
| 4565 | __ CompareRoot(r0, Heap::kNullValueRootIndex); |
| 4566 | __ b(eq, if_true); |
| 4567 | } |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4568 | // Check for JS objects => true. |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 4569 | __ CompareObjectType(r0, r0, r1, FIRST_NONCALLABLE_SPEC_OBJECT_TYPE); |
| 4570 | __ b(lt, if_false); |
| 4571 | __ CompareInstanceType(r0, r1, LAST_NONCALLABLE_SPEC_OBJECT_TYPE); |
| 4572 | __ b(gt, if_false); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 4573 | // Check for undetectable objects => false. |
| 4574 | __ ldrb(r1, FieldMemOperand(r0, Map::kBitFieldOffset)); |
| 4575 | __ tst(r1, Operand(1 << Map::kIsUndetectable)); |
| 4576 | Split(eq, if_true, if_false, fall_through); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4577 | } else { |
| 4578 | if (if_false != fall_through) __ jmp(if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 4579 | } |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4580 | context()->Plug(if_true, if_false); |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 4581 | } |
| 4582 | |
| 4583 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4584 | void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) { |
| 4585 | Comment cmnt(masm_, "[ CompareOperation"); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4586 | SetSourcePosition(expr->position()); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4587 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4588 | // First we try a fast inlined version of the compare when one of |
| 4589 | // the operands is a literal. |
| 4590 | if (TryLiteralCompare(expr)) return; |
| 4591 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4592 | // Always perform the comparison for its control flow. Pack the result |
| 4593 | // into the expression's context after the comparison is performed. |
kmillikin@chromium.org | 9155e25 | 2010-05-26 13:27:57 +0000 | [diff] [blame] | 4594 | Label materialize_true, materialize_false; |
| 4595 | Label* if_true = NULL; |
| 4596 | Label* if_false = NULL; |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4597 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4598 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 4599 | &if_true, &if_false, &fall_through); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4600 | |
ager@chromium.org | 04921a8 | 2011-06-27 13:21:41 +0000 | [diff] [blame] | 4601 | Token::Value op = expr->op(); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4602 | VisitForStackValue(expr->left()); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4603 | switch (op) { |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4604 | case Token::IN: |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4605 | VisitForStackValue(expr->right()); |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 4606 | __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4607 | PrepareForBailoutBeforeSplit(expr, false, NULL, NULL); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4608 | __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
| 4609 | __ cmp(r0, ip); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4610 | Split(eq, if_true, if_false, fall_through); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4611 | break; |
| 4612 | |
| 4613 | case Token::INSTANCEOF: { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4614 | VisitForStackValue(expr->right()); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 4615 | InstanceofStub stub(InstanceofStub::kNoFlags); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4616 | __ CallStub(&stub); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4617 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4618 | // The stub returns 0 for true. |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4619 | __ tst(r0, r0); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4620 | Split(eq, if_true, if_false, fall_through); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4621 | break; |
| 4622 | } |
| 4623 | |
| 4624 | default: { |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4625 | VisitForAccumulatorValue(expr->right()); |
yangguo@chromium.org | fb37721 | 2012-11-16 14:43:43 +0000 | [diff] [blame] | 4626 | Condition cond = CompareIC::ComputeCondition(op); |
erik.corry@gmail.com | 394dbcf | 2011-10-27 07:38:48 +0000 | [diff] [blame] | 4627 | __ pop(r1); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4628 | |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 4629 | bool inline_smi_code = ShouldInlineSmiCase(op); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4630 | JumpPatchSite patch_site(masm_); |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 4631 | if (inline_smi_code) { |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4632 | Label slow_case; |
| 4633 | __ orr(r2, r0, Operand(r1)); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4634 | patch_site.EmitJumpIfNotSmi(r2, &slow_case); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4635 | __ cmp(r1, r0); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4636 | Split(cond, if_true, if_false, NULL); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4637 | __ bind(&slow_case); |
| 4638 | } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 4639 | |
| 4640 | // Record position and call the compare IC. |
| 4641 | SetSourcePosition(expr->position()); |
hpayer@chromium.org | 8432c91 | 2013-02-28 15:55:26 +0000 | [diff] [blame] | 4642 | Handle<Code> ic = CompareIC::GetUninitialized(isolate(), op); |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 4643 | CallIC(ic, RelocInfo::CODE_TARGET, expr->CompareOperationFeedbackId()); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4644 | patch_site.EmitPatchInfo(); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4645 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
jkummerow@chromium.org | 59297c7 | 2013-01-09 16:32:23 +0000 | [diff] [blame] | 4646 | __ cmp(r0, Operand::Zero()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 4647 | Split(cond, if_true, if_false, fall_through); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4648 | } |
| 4649 | } |
| 4650 | |
| 4651 | // Convert the result of the comparison into one expected for this |
| 4652 | // expression's context. |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4653 | context()->Plug(if_true, if_false); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4654 | } |
| 4655 | |
| 4656 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4657 | void FullCodeGenerator::EmitLiteralCompareNil(CompareOperation* expr, |
| 4658 | Expression* sub_expr, |
| 4659 | NilValue nil) { |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4660 | Label materialize_true, materialize_false; |
| 4661 | Label* if_true = NULL; |
| 4662 | Label* if_false = NULL; |
| 4663 | Label* fall_through = NULL; |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4664 | context()->PrepareTest(&materialize_true, &materialize_false, |
| 4665 | &if_true, &if_false, &fall_through); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4666 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 4667 | VisitForAccumulatorValue(sub_expr); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 4668 | PrepareForBailoutBeforeSplit(expr, true, if_true, if_false); |
ulan@chromium.org | 837a67e | 2013-06-11 15:39:48 +0000 | [diff] [blame] | 4669 | if (expr->op() == Token::EQ_STRICT) { |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 4670 | Heap::RootListIndex nil_value = nil == kNullValue ? |
| 4671 | Heap::kNullValueRootIndex : |
| 4672 | Heap::kUndefinedValueRootIndex; |
| 4673 | __ LoadRoot(r1, nil_value); |
| 4674 | __ cmp(r0, r1); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4675 | Split(eq, if_true, if_false, fall_through); |
| 4676 | } else { |
ulan@chromium.org | 837a67e | 2013-06-11 15:39:48 +0000 | [diff] [blame] | 4677 | Handle<Code> ic = CompareNilICStub::GetUninitialized(isolate(), nil); |
danno@chromium.org | ca29dd8 | 2013-04-26 11:59:48 +0000 | [diff] [blame] | 4678 | CallIC(ic, RelocInfo::CODE_TARGET, expr->CompareOperationFeedbackId()); |
| 4679 | __ cmp(r0, Operand(0)); |
| 4680 | Split(ne, if_true, if_false, fall_through); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4681 | } |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4682 | context()->Plug(if_true, if_false); |
ricow@chromium.org | 65fae84 | 2010-08-25 15:26:24 +0000 | [diff] [blame] | 4683 | } |
| 4684 | |
| 4685 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4686 | void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
| 4687 | __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 4688 | context()->Plug(r0); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4689 | } |
| 4690 | |
| 4691 | |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 4692 | Register FullCodeGenerator::result_register() { |
| 4693 | return r0; |
| 4694 | } |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4695 | |
| 4696 | |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 4697 | Register FullCodeGenerator::context_register() { |
| 4698 | return cp; |
| 4699 | } |
| 4700 | |
| 4701 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4702 | void FullCodeGenerator::StoreToFrameField(int frame_offset, Register value) { |
| 4703 | ASSERT_EQ(POINTER_SIZE_ALIGN(frame_offset), frame_offset); |
| 4704 | __ str(value, MemOperand(fp, frame_offset)); |
| 4705 | } |
| 4706 | |
| 4707 | |
| 4708 | void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
sgjesse@chromium.org | 2ec107f | 2010-09-13 09:19:46 +0000 | [diff] [blame] | 4709 | __ ldr(dst, ContextOperand(cp, context_index)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4710 | } |
| 4711 | |
| 4712 | |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 4713 | void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4714 | Scope* declaration_scope = scope()->DeclarationScope(); |
erik.corry@gmail.com | ed49e96 | 2012-04-17 11:57:53 +0000 | [diff] [blame] | 4715 | if (declaration_scope->is_global_scope() || |
| 4716 | declaration_scope->is_module_scope()) { |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 4717 | // Contexts nested in the native context have a canonical empty function |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 4718 | // as their closure, not the anonymous closure containing the global |
| 4719 | // code. Pass a smi sentinel and let the runtime look up the empty |
| 4720 | // function. |
| 4721 | __ mov(ip, Operand(Smi::FromInt(0))); |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4722 | } else if (declaration_scope->is_eval_scope()) { |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 4723 | // Contexts created by a call to eval have the same closure as the |
| 4724 | // context calling eval, not the anonymous closure containing the eval |
| 4725 | // code. Fetch it from the context. |
| 4726 | __ ldr(ip, ContextOperand(cp, Context::CLOSURE_INDEX)); |
| 4727 | } else { |
ricow@chromium.org | 4f693d6 | 2011-07-04 14:01:31 +0000 | [diff] [blame] | 4728 | ASSERT(declaration_scope->is_function_scope()); |
vegorov@chromium.org | 3cf4731 | 2011-06-29 13:20:01 +0000 | [diff] [blame] | 4729 | __ ldr(ip, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 4730 | } |
| 4731 | __ push(ip); |
| 4732 | } |
| 4733 | |
| 4734 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4735 | // ---------------------------------------------------------------------------- |
| 4736 | // Non-local control flow support. |
| 4737 | |
| 4738 | void FullCodeGenerator::EnterFinallyBlock() { |
| 4739 | ASSERT(!result_register().is(r1)); |
| 4740 | // Store result register while executing finally block. |
| 4741 | __ push(result_register()); |
| 4742 | // Cook return address in link register to stack (smi encoded Code* delta) |
| 4743 | __ sub(r1, lr, Operand(masm_->CodeObject())); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 4744 | __ SmiTag(r1); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4745 | |
| 4746 | // Store result register while executing finally block. |
| 4747 | __ push(r1); |
| 4748 | |
| 4749 | // Store pending message while executing finally block. |
| 4750 | ExternalReference pending_message_obj = |
| 4751 | ExternalReference::address_of_pending_message_obj(isolate()); |
| 4752 | __ mov(ip, Operand(pending_message_obj)); |
| 4753 | __ ldr(r1, MemOperand(ip)); |
| 4754 | __ push(r1); |
| 4755 | |
| 4756 | ExternalReference has_pending_message = |
| 4757 | ExternalReference::address_of_has_pending_message(isolate()); |
| 4758 | __ mov(ip, Operand(has_pending_message)); |
| 4759 | __ ldr(r1, MemOperand(ip)); |
verwaest@chromium.org | 753aee4 | 2012-07-17 16:15:42 +0000 | [diff] [blame] | 4760 | __ SmiTag(r1); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4761 | __ push(r1); |
| 4762 | |
| 4763 | ExternalReference pending_message_script = |
| 4764 | ExternalReference::address_of_pending_message_script(isolate()); |
| 4765 | __ mov(ip, Operand(pending_message_script)); |
| 4766 | __ ldr(r1, MemOperand(ip)); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4767 | __ push(r1); |
| 4768 | } |
| 4769 | |
| 4770 | |
| 4771 | void FullCodeGenerator::ExitFinallyBlock() { |
| 4772 | ASSERT(!result_register().is(r1)); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4773 | // Restore pending message from stack. |
| 4774 | __ pop(r1); |
| 4775 | ExternalReference pending_message_script = |
| 4776 | ExternalReference::address_of_pending_message_script(isolate()); |
| 4777 | __ mov(ip, Operand(pending_message_script)); |
| 4778 | __ str(r1, MemOperand(ip)); |
| 4779 | |
| 4780 | __ pop(r1); |
verwaest@chromium.org | 753aee4 | 2012-07-17 16:15:42 +0000 | [diff] [blame] | 4781 | __ SmiUntag(r1); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4782 | ExternalReference has_pending_message = |
| 4783 | ExternalReference::address_of_has_pending_message(isolate()); |
| 4784 | __ mov(ip, Operand(has_pending_message)); |
| 4785 | __ str(r1, MemOperand(ip)); |
| 4786 | |
| 4787 | __ pop(r1); |
| 4788 | ExternalReference pending_message_obj = |
| 4789 | ExternalReference::address_of_pending_message_obj(isolate()); |
| 4790 | __ mov(ip, Operand(pending_message_obj)); |
| 4791 | __ str(r1, MemOperand(ip)); |
| 4792 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4793 | // Restore result register from stack. |
| 4794 | __ pop(r1); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 4795 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4796 | // Uncook return address and return. |
| 4797 | __ pop(result_register()); |
ulan@chromium.org | bf9432e | 2013-05-22 14:05:23 +0000 | [diff] [blame] | 4798 | __ SmiUntag(r1); |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4799 | __ add(pc, r1, Operand(masm_->CodeObject())); |
| 4800 | } |
| 4801 | |
| 4802 | |
| 4803 | #undef __ |
| 4804 | |
jkummerow@chromium.org | 486075a | 2011-09-07 12:44:28 +0000 | [diff] [blame] | 4805 | #define __ ACCESS_MASM(masm()) |
| 4806 | |
| 4807 | FullCodeGenerator::NestedStatement* FullCodeGenerator::TryFinally::Exit( |
| 4808 | int* stack_depth, |
| 4809 | int* context_length) { |
| 4810 | // The macros used here must preserve the result register. |
| 4811 | |
| 4812 | // Because the handler block contains the context of the finally |
| 4813 | // code, we can restore it directly from there for the finally code |
| 4814 | // rather than iteratively unwinding contexts via their previous |
| 4815 | // links. |
| 4816 | __ Drop(*stack_depth); // Down to the handler block. |
| 4817 | if (*context_length > 0) { |
| 4818 | // Restore the context to its dedicated register and the stack. |
| 4819 | __ ldr(cp, MemOperand(sp, StackHandlerConstants::kContextOffset)); |
| 4820 | __ str(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 4821 | } |
| 4822 | __ PopTryHandler(); |
| 4823 | __ bl(finally_entry_); |
| 4824 | |
| 4825 | *stack_depth = 0; |
| 4826 | *context_length = 0; |
| 4827 | return previous_; |
| 4828 | } |
| 4829 | |
| 4830 | |
| 4831 | #undef __ |
| 4832 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4833 | |
| 4834 | static const int32_t kBranchBeforeInterrupt = 0x5a000004; |
| 4835 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4836 | |
| 4837 | void BackEdgeTable::PatchAt(Code* unoptimized_code, |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4838 | Address pc, |
| 4839 | BackEdgeState target_state, |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4840 | Code* replacement_code) { |
| 4841 | static const int kInstrSize = Assembler::kInstrSize; |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4842 | Address branch_address = pc - 3 * kInstrSize; |
| 4843 | CodePatcher patcher(branch_address, 1); |
| 4844 | |
| 4845 | switch (target_state) { |
| 4846 | case INTERRUPT: |
| 4847 | // <decrement profiling counter> |
| 4848 | // 2a 00 00 01 bpl ok |
| 4849 | // e5 9f c? ?? ldr ip, [pc, <interrupt stub address>] |
| 4850 | // e1 2f ff 3c blx ip |
| 4851 | // ok-label |
| 4852 | patcher.masm()->b(4 * kInstrSize, pl); // Jump offset is 4 instructions. |
| 4853 | ASSERT_EQ(kBranchBeforeInterrupt, Memory::int32_at(branch_address)); |
| 4854 | break; |
| 4855 | case ON_STACK_REPLACEMENT: |
| 4856 | case OSR_AFTER_STACK_CHECK: |
| 4857 | // <decrement profiling counter> |
| 4858 | // e1 a0 00 00 mov r0, r0 (NOP) |
| 4859 | // e5 9f c? ?? ldr ip, [pc, <on-stack replacement address>] |
| 4860 | // e1 2f ff 3c blx ip |
| 4861 | // ok-label |
| 4862 | patcher.masm()->nop(); |
| 4863 | break; |
| 4864 | } |
| 4865 | |
| 4866 | Address pc_immediate_load_address = pc - 2 * kInstrSize; |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4867 | // Replace the call address. |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4868 | uint32_t interrupt_address_offset = |
| 4869 | Memory::uint16_at(pc_immediate_load_address) & 0xfff; |
| 4870 | Address interrupt_address_pointer = pc + interrupt_address_offset; |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4871 | Memory::uint32_at(interrupt_address_pointer) = |
| 4872 | reinterpret_cast<uint32_t>(replacement_code->entry()); |
| 4873 | |
| 4874 | unoptimized_code->GetHeap()->incremental_marking()->RecordCodeTargetPatch( |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4875 | unoptimized_code, pc_immediate_load_address, replacement_code); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4876 | } |
| 4877 | |
| 4878 | |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4879 | BackEdgeTable::BackEdgeState BackEdgeTable::GetBackEdgeState( |
| 4880 | Isolate* isolate, |
| 4881 | Code* unoptimized_code, |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4882 | Address pc) { |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4883 | static const int kInstrSize = Assembler::kInstrSize; |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4884 | ASSERT(Memory::int32_at(pc - kInstrSize) == kBlxIp); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4885 | |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4886 | Address branch_address = pc - 3 * kInstrSize; |
| 4887 | Address pc_immediate_load_address = pc - 2 * kInstrSize; |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4888 | uint32_t interrupt_address_offset = |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4889 | Memory::uint16_at(pc_immediate_load_address) & 0xfff; |
| 4890 | Address interrupt_address_pointer = pc + interrupt_address_offset; |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4891 | |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4892 | if (Memory::int32_at(branch_address) == kBranchBeforeInterrupt) { |
| 4893 | ASSERT(Memory::uint32_at(interrupt_address_pointer) == |
| 4894 | reinterpret_cast<uint32_t>( |
| 4895 | isolate->builtins()->InterruptCheck()->entry())); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4896 | ASSERT(Assembler::IsLdrPcImmediateOffset( |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4897 | Assembler::instr_at(pc_immediate_load_address))); |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4898 | return INTERRUPT; |
| 4899 | } |
machenbach@chromium.org | 8e36b5b | 2013-09-26 07:36:30 +0000 | [diff] [blame] | 4900 | |
| 4901 | ASSERT(Assembler::IsNop(Assembler::instr_at(branch_address))); |
| 4902 | ASSERT(Assembler::IsLdrPcImmediateOffset( |
| 4903 | Assembler::instr_at(pc_immediate_load_address))); |
| 4904 | |
| 4905 | if (Memory::uint32_at(interrupt_address_pointer) == |
| 4906 | reinterpret_cast<uint32_t>( |
| 4907 | isolate->builtins()->OnStackReplacement()->entry())) { |
| 4908 | return ON_STACK_REPLACEMENT; |
| 4909 | } |
| 4910 | |
| 4911 | ASSERT(Memory::uint32_at(interrupt_address_pointer) == |
| 4912 | reinterpret_cast<uint32_t>( |
| 4913 | isolate->builtins()->OsrAfterStackCheck()->entry())); |
| 4914 | return OSR_AFTER_STACK_CHECK; |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4915 | } |
machenbach@chromium.org | 528ce02 | 2013-09-23 14:09:36 +0000 | [diff] [blame] | 4916 | |
| 4917 | |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 4918 | } } // namespace v8::internal |
erik.corry@gmail.com | 9dfbea4 | 2010-05-21 12:58:28 +0000 | [diff] [blame] | 4919 | |
| 4920 | #endif // V8_TARGET_ARCH_ARM |