| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 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 |
| 29 |
| 30 #include "v8.h" |
| 31 |
| 32 #include "codegen-inl.h" |
| 33 #include "debug.h" |
| 34 #include "runtime.h" |
| 35 |
| 36 namespace v8 { |
| 37 namespace internal { |
| 38 |
| 39 |
| 40 #define __ ACCESS_MASM(masm) |
| 41 |
| 42 |
| 43 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id) { |
| 44 UNIMPLEMENTED_(); |
| 45 // // TODO(428): Don't pass the function in a static variable. |
| 46 //// __ mov(ip, Operand(ExternalReference::builtin_passed_function())); |
| 47 //// __ str(r1, MemOperand(ip, 0)); |
| 48 // __ li(ip, Operand(ExternalReference::builtin_passed_function())); |
| 49 // __ sw(a1, MemOperand(ip, 0)); |
| 50 // |
| 51 // // The actual argument count has already been loaded into register |
| 52 // // r0, but JumpToBuiltin expects r0 to contain the number of |
| 53 // // arguments including the receiver. |
| 54 //// __ add(r0, r0, Operand(1)); |
| 55 //// __ JumpToRuntime(ExternalReference(id)); |
| 56 // __ addi(a0, a0, Operand(1)); |
| 57 // // This is really ugly... |
| 58 // // in Builtins::Generate_JSConstructStubGeneric we allocate some args slots |
| 59 // // because some functions need it. But here we do not expect them. |
| 60 //// __ break_(0x00001); |
| 61 //// __ addiu(sp, sp, StandardFrameConstants::kRArgsSlotsSize); |
| 62 // __ JumpToRuntime(ExternalReference(id)); |
| 63 // __ nop(); // NOP_ADDED |
| 64 } |
| 65 |
| 66 |
| 67 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { |
| 68 UNIMPLEMENTED_(); |
| 69 // // Just jump to the generic array code. |
| 70 //// __ break_(0x00002); |
| 71 // Code* code = Builtins::builtin(Builtins::ArrayCodeGeneric); |
| 72 // Handle<Code> array_code(code); |
| 73 // __ Jump(array_code, RelocInfo::CODE_TARGET); |
| 74 // __ nop(); // NOP_ADDED |
| 75 } |
| 76 |
| 77 |
| 78 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { |
| 79 UNIMPLEMENTED_(); |
| 80 // // Just jump to the generic construct code. |
| 81 // Code* code = Builtins::builtin(Builtins::JSConstructStubGeneric); |
| 82 // Handle<Code> generic_construct_stub(code); |
| 83 // __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 84 // __ nop(); // NOP_ADDED |
| 85 } |
| 86 |
| 87 |
| 88 void Builtins::Generate_JSConstructCall(MacroAssembler* masm) { |
| 89 UNIMPLEMENTED_(); |
| 90 // // ----------- S t a t e ------------- |
| 91 // // -- a0 : number of arguments |
| 92 // // -- a1 : constructor function |
| 93 // // -- ra : return address |
| 94 // // -- sp[...]: constructor arguments |
| 95 // // ----------------------------------- |
| 96 // |
| 97 // __ li(at, Operand(0xe)); |
| 98 // __ teq(a1, at, 0x123); |
| 99 // Label non_function_call; |
| 100 // // Check that the function is not a smi. |
| 101 // __ andi(t0, a1, Operand(kSmiTagMask)); |
| 102 // __ beq(t0, zero_reg, &non_function_call); |
| 103 // __ nop(); // NOP_ADDED |
| 104 // // Check that the function is a JSFunction. |
| 105 // __ GetObjectType(a1, a2, a2); |
| 106 // __ bcond(ne, &non_function_call, a2, Operand(JS_FUNCTION_TYPE)); |
| 107 // __ nop(); // NOP_ADDED |
| 108 // |
| 109 // // Jump to the function-specific construct stub. |
| 110 //// __ ldr(r2, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 111 //// __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kConstructStubOffset)); |
| 112 //// __ add(pc, r2, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 113 // __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
| 114 // __ lw(a2, FieldMemOperand(a2, SharedFunctionInfo::kConstructStubOffset)); |
| 115 // __ addiu(t9, a2, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 116 // __ jr(Operand(t9)); |
| 117 // __ nop(); // NOP_ADDED |
| 118 // |
| 119 // // r0: number of arguments |
| 120 // // r1: called object |
| 121 // __ bind(&non_function_call); |
| 122 //// __ break_(0x04301); |
| 123 // |
| 124 // // Set expected number of arguments to zero (not changing r0). |
| 125 //// __ mov(r2, Operand(0)); |
| 126 //// __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
| 127 //// __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), |
| 128 //// RelocInfo::CODE_TARGET); |
| 129 // __ li(a2, Operand(0)); |
| 130 // __ GetBuiltinEntry(a3, Builtins::CALL_NON_FUNCTION_AS_CONSTRUCTOR); |
| 131 //// __ break_(0x124); |
| 132 // __ li(v1, Operand(0)); // Tell ArgumentsAdaptorTrampoline we need args slots |
| 133 // __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), |
| 134 // RelocInfo::CODE_TARGET); |
| 135 // __ nop(); // NOP_ADDED |
| 136 } |
| 137 |
| 138 |
| 139 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
| 140 UNIMPLEMENTED_(); |
| 141 // |
| 142 // |
| 143 // // Enter a construct frame. |
| 144 // __ EnterConstructFrame(); |
| 145 // |
| 146 // // Preserve the two incoming parameters on the stack. |
| 147 // // a0: Smi-tagged arguments count. a1: Constructor function. |
| 148 // __ sll(a0, a0, kSmiTagSize); |
| 149 // __ multi_push(a0.bit() | a1.bit()); |
| 150 // |
| 151 // // Use t7 to hold undefined, which is used in several places below. |
| 152 // __ LoadRoot(t7, Heap::kUndefinedValueRootIndex); |
| 153 // |
| 154 // Label rt_call, allocated; |
| 155 // // Try to allocate the object without transitioning into C code. If any of t
he |
| 156 // // preconditions is not met, the code bails out to the runtime call. |
| 157 // if (FLAG_inline_new) { |
| 158 // Label undo_allocation; |
| 159 //#ifdef ENABLE_DEBUGGER_SUPPORT |
| 160 // ExternalReference debug_step_in_fp = |
| 161 // ExternalReference::debug_step_in_fp_address(); |
| 162 // __ li(a2, Operand(debug_step_in_fp)); |
| 163 // __ lw(a2, MemOperand(a2)); |
| 164 // __ bne(a2, zero_reg, &rt_call); |
| 165 // __ nop(); // NOP_ADDED |
| 166 //#endif |
| 167 // |
| 168 // // Load the initial map and verify that it is in fact a map. |
| 169 // // r1->a1: constructor function |
| 170 // // r7->t7: undefined |
| 171 //// __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)
); |
| 172 //// __ tst(r2, Operand(kSmiTagMask)); |
| 173 //// __ b(eq, &rt_call); |
| 174 //// __ CompareObjectType(r2, r3, r4, MAP_TYPE); |
| 175 //// __ b(ne, &rt_call); |
| 176 // __ lw(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); |
| 177 // __ andi(t0, a2, Operand(kSmiTagMask)); |
| 178 // __ beq(t0, zero_reg, &rt_call); |
| 179 // __ nop(); // NOP_ADDED |
| 180 // __ GetObjectType(a2, a3, t4); |
| 181 // __ bcond(ne, &rt_call, t4, Operand(MAP_TYPE)); |
| 182 // __ nop(); // NOP_ADDED |
| 183 // |
| 184 // // Check that the constructor is not constructing a JSFunction (see commen
ts |
| 185 // // in Runtime_NewObject in runtime.cc). In which case the initial map's |
| 186 // // instance type would be JS_FUNCTION_TYPE. |
| 187 // // r1->a1: constructor function |
| 188 // // r2->a2: initial map |
| 189 // // r7->t7: undefined |
| 190 //// __ CompareInstanceType(r2, r3, JS_FUNCTION_TYPE); |
| 191 // __ lbu(a3, FieldMemOperand(a2, Map::kInstanceTypeOffset)); |
| 192 // __ bcond(eq, &rt_call, a3, Operand(JS_FUNCTION_TYPE)); |
| 193 // __ nop(); // NOP_ADDED |
| 194 // |
| 195 // // Now allocate the JSObject on the heap. |
| 196 // // r1->a1: constructor function |
| 197 // // r2->a2: initial map |
| 198 // // r7->t7: undefined |
| 199 //// __ ldrb(r3, FieldMemOperand(r2, Map::kInstanceSizeOffset)); |
| 200 // __ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset)); |
| 201 // __ AllocateInNewSpace(a3, t4, t5, t6, &rt_call, NO_ALLOCATION_FLAGS); |
| 202 // |
| 203 // // Allocated the JSObject, now initialize the fields. Map is set to initia
l |
| 204 // // map and properties and elements are set to empty fixed array. |
| 205 // // r1->a1: constructor function |
| 206 // // r2->a2: initial map |
| 207 // // r3->a3: object size |
| 208 // // r4->t4: JSObject (not tagged) |
| 209 // // r7->t7: undefined |
| 210 //// __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
| 211 //// __ mov(r5, r4); |
| 212 // __ LoadRoot(t6, Heap::kEmptyFixedArrayRootIndex); |
| 213 // __ mov(t5, t4); |
| 214 //// __ str(r2, MemOperand(r5, kPointerSize, PostIndex)); |
| 215 //// __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
| 216 //// __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
| 217 // __ sw(a2, MemOperand(t5, JSObject::kMapOffset)); |
| 218 // __ sw(t6, MemOperand(t5, JSObject::kPropertiesOffset)); |
| 219 // __ sw(t6, MemOperand(t5, JSObject::kElementsOffset)); |
| 220 // __ addiu(t5, t5, Operand(3*kPointerSize)); |
| 221 // |
| 222 // ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset); |
| 223 // ASSERT_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); |
| 224 // ASSERT_EQ(2 * kPointerSize, JSObject::kElementsOffset); |
| 225 // |
| 226 // |
| 227 // // Fill all the in-object properties with undefined. |
| 228 // // r1->a1: constructor function |
| 229 // // r2->a2: initial map |
| 230 // // r3->a3: object size (in words) |
| 231 // // r4->t4: JSObject (not tagged) |
| 232 // // r5->t5: First in-object property of JSObject (not tagged) |
| 233 // // r7->t7: undefined |
| 234 //// __ add(r6, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
| 235 // __ sll(t0, a3, kPointerSizeLog2); |
| 236 // __ add(t6, t4, t0); // End of object. |
| 237 // ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize); |
| 238 // { Label loop, entry; |
| 239 // __ b(&entry); |
| 240 // __ nop(); // NOP_ADDED |
| 241 // __ bind(&loop); |
| 242 //// __ str(r7, MemOperand(r5, kPointerSize, PostIndex)); |
| 243 // __ sw(t7, MemOperand(t5, 0)); |
| 244 // __ addiu(t5, Operand(kPointerSize)); |
| 245 // __ bind(&entry); |
| 246 //// __ cmp(r5, Operand(r6)); |
| 247 //// __ b(lt, &loop); |
| 248 // __ bcond(less, &loop, t5, Operand(t6)); |
| 249 // __ nop(); // NOP_ADDED |
| 250 // } |
| 251 // |
| 252 // // Add the object tag to make the JSObject real, so that we can continue a
nd |
| 253 // // jump into the continuation code at any time from now on. Any failures |
| 254 // // need to undo the allocation, so that the heap is in a consistent state |
| 255 // // and verifiable. |
| 256 //// __ add(r4, r4, Operand(kHeapObjectTag)); |
| 257 // __ addiu(t4, t4, Operand(kHeapObjectTag)); |
| 258 // |
| 259 // // Check if a non-empty properties array is needed. Continue with allocate
d |
| 260 // // object if not fall through to runtime call if it is. |
| 261 // // r1->a1: constructor function |
| 262 // // r4->t0: JSObject |
| 263 // // r5->t1: start of next object (not tagged) |
| 264 // // r7->t7: undefined |
| 265 //// __ ldrb(r3, FieldMemOperand(r2, Map::kUnusedPropertyFieldsOffset)); |
| 266 // __ lbu(a3, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset)); |
| 267 // // The field instance sizes contains both pre-allocated property fields an
d |
| 268 // // in-object properties. |
| 269 //// __ ldr(r0, FieldMemOperand(r2, Map::kInstanceSizesOffset)); |
| 270 //// __ and_(r6, |
| 271 //// r0, |
| 272 //// Operand(0x000000FF << Map::kPreAllocatedPropertyFieldsByte * 8))
; |
| 273 //// __ add(r3, r3, Operand(r6, LSR, Map::kPreAllocatedPropertyFieldsByte * 8
)); |
| 274 //// __ and_(r6, r0, Operand(0x000000FF << Map::kInObjectPropertiesByte * 8))
; |
| 275 //// __ sub(r3, r3, Operand(r6, LSR, Map::kInObjectPropertiesByte * 8), SetCC
); |
| 276 // __ lw(a0, FieldMemOperand(a2, Map::kInstanceSizesOffset)); |
| 277 // __ andi(t6, |
| 278 // a0, |
| 279 // Operand(0x000000FF << Map::kPreAllocatedPropertyFieldsByte * 8)); |
| 280 // __ srl(t0, t6, Map::kPreAllocatedPropertyFieldsByte * 8); |
| 281 // __ addu(a3, a3, Operand(t0)); |
| 282 // __ and_(t6, a0, Operand(0x000000FF << Map::kInObjectPropertiesByte * 8)); |
| 283 // __ srl(t0, t6, Map::kInObjectPropertiesByte * 8); |
| 284 // __ sub(a3, a3, Operand(t0)); |
| 285 // |
| 286 // // Done if no extra properties are to be allocated. |
| 287 //// __ b(eq, &allocated); |
| 288 // __ beq(a3, zero_reg, &allocated); |
| 289 // __ nop(); // NOP_ADDED |
| 290 // __ Assert(greater_equal, "Property allocation count failed.", a3, Operand(
zero_reg)); |
| 291 // |
| 292 // // Scale the number of elements by pointer size and add the header for |
| 293 // // FixedArrays to the start of the next object calculation from above. |
| 294 // // r1->a1: constructor |
| 295 // // r3->a3: number of elements in properties array |
| 296 // // r4->t4: JSObject |
| 297 // // r5->t5: start of next object |
| 298 // // r7->t7: undefined |
| 299 //// __ add(r0, r3, Operand(FixedArray::kHeaderSize / kPointerSize)); |
| 300 // __ addiu(a0, a3, Operand(FixedArray::kHeaderSize / kPointerSize)); |
| 301 // __ AllocateInNewSpace(a0, |
| 302 // t5, |
| 303 // t6, |
| 304 // a2, |
| 305 // &undo_allocation, |
| 306 // RESULT_CONTAINS_TOP); |
| 307 // |
| 308 // // Initialize the FixedArray. |
| 309 // // r1->a1: constructor |
| 310 // // r3->a3: number of elements in properties array |
| 311 // // r4->t4: JSObject |
| 312 // // r5->t5: start of next object |
| 313 // // r7->t7: undefined |
| 314 // __ LoadRoot(t6, Heap::kFixedArrayMapRootIndex); |
| 315 //// __ mov(r2, r5); |
| 316 // __ mov(a2, t5); |
| 317 // ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset); |
| 318 //// __ str(r6, MemOperand(r2, kPointerSize, PostIndex)); |
| 319 // __ sw(t6, MemOperand(a2, JSObject::kMapOffset)); |
| 320 // ASSERT_EQ(1 * kPointerSize, Array::kLengthOffset); |
| 321 //// __ str(r3, MemOperand(r2, kPointerSize, PostIndex)); |
| 322 // __ sw(a3, MemOperand(a2, Array::kLengthOffset)); |
| 323 // |
| 324 // __ addiu(a2, a2, Operand(2*kPointerSize)); |
| 325 // |
| 326 // // Initialize the fields to undefined. |
| 327 // // r1->a1: constructor |
| 328 // // r2->a2: First element of FixedArray (not tagged) |
| 329 // // r3->a3: number of elements in properties array |
| 330 // // r4->t4: JSObject |
| 331 // // r5->t5: FixedArray (not tagged) |
| 332 // // r7->t7: undefined |
| 333 //// __ add(r6, r2, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
| 334 // __ sll(t3, a3, kPointerSizeLog2); |
| 335 // __ add(t6, a2, Operand(t3)); // End of object. |
| 336 // ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize); |
| 337 // { Label loop, entry; |
| 338 // __ b(&entry); |
| 339 // __ nop(); // NOP_ADDED |
| 340 // __ bind(&loop); |
| 341 //// __ str(r7, MemOperand(r2, kPointerSize, PostIndex)); |
| 342 //// __ bind(&entry); |
| 343 //// __ cmp(r2, Operand(r6)); |
| 344 //// __ b(lt, &loop); |
| 345 // __ sw(t7, MemOperand(a2)); |
| 346 // __ addiu(a2, a2, kPointerSize); |
| 347 // __ bind(&entry); |
| 348 // __ bcond(less, &loop, a2, Operand(t6)); |
| 349 // __ nop(); // NOP_ADDED |
| 350 // } |
| 351 // |
| 352 // // Store the initialized FixedArray into the properties field of |
| 353 // // the JSObject |
| 354 // // r1->a1: constructor function |
| 355 // // r4->t4: JSObject |
| 356 // // r5->t5: FixedArray (not tagged) |
| 357 //// __ add(r5, r5, Operand(kHeapObjectTag)); // Add the heap tag. |
| 358 //// __ str(r5, FieldMemOperand(r4, JSObject::kPropertiesOffset)); |
| 359 // __ addiu(t5, t5, Operand(kHeapObjectTag)); // Add the heap tag. |
| 360 // __ sw(t5, FieldMemOperand(t4, JSObject::kPropertiesOffset)); |
| 361 // |
| 362 // // Continue with JSObject being successfully allocated |
| 363 // // r1: constructor function |
| 364 // // r4: JSObject |
| 365 //// __ jmp(&allocated); |
| 366 // __ b(&allocated); |
| 367 // __ nop(); // NOP_ADDED |
| 368 // |
| 369 // // Undo the setting of the new top so that the heap is verifiable. For |
| 370 // // example, the map's unused properties potentially do not match the |
| 371 // // allocated objects unused properties. |
| 372 // // r4: JSObject (previous new top) |
| 373 // __ bind(&undo_allocation); |
| 374 // __ UndoAllocationInNewSpace(t4, t5); |
| 375 // } |
| 376 // |
| 377 // __ bind(&rt_call); |
| 378 // // Allocate the new receiver object using the runtime call. |
| 379 // // r1->a1: constructor function |
| 380 // __ push(a1); // argument for Runtime_NewObject |
| 381 // __ CallRuntime(Runtime::kNewObject, 1); |
| 382 // __ nop(); |
| 383 //// __ mov(r4, r0) |
| 384 // __ mov(t4, v0); |
| 385 // |
| 386 // // Receiver for constructor call allocated. |
| 387 // // r4->t0: JSObject |
| 388 // __ bind(&allocated); |
| 389 //// __ push(r4); |
| 390 // __ push(t4); |
| 391 // |
| 392 // // Push the function and the allocated receiver from the stack. |
| 393 // // sp[0]: receiver (newly allocated object) |
| 394 // // sp[1]: constructor function |
| 395 // // sp[2]: number of arguments (smi-tagged) |
| 396 //// __ ldr(r1, MemOperand(sp, kPointerSize)); |
| 397 //// __ push(r1); // Constructor function. |
| 398 //// __ push(r4); // Receiver. |
| 399 // __ lw(a1, MemOperand(sp, kPointerSize)); |
| 400 // __ push(a1); // Constructor function. |
| 401 // __ push(t4); // Receiver. |
| 402 // |
| 403 // // Reload the number of arguments from the stack. |
| 404 // // r1->a1: constructor function |
| 405 // // sp[0]: receiver |
| 406 // // sp[1]: constructor function |
| 407 // // sp[2]: receiver |
| 408 // // sp[3]: constructor function |
| 409 // // sp[4]: number of arguments (smi-tagged) |
| 410 //// __ ldr(r3, MemOperand(sp, 4 * kPointerSize)); |
| 411 // __ lw(a3, MemOperand(sp, 4 * kPointerSize)); |
| 412 // |
| 413 // // Setup pointer to last argument. |
| 414 //// __ add(r2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 415 // __ addiu(a2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); |
| 416 //// + StandardFrameConstants::kRegularArgsSlotsSize)); |
| 417 // |
| 418 // // Setup number of arguments for function call below |
| 419 //// __ mov(r0, Operand(r3, LSR, kSmiTagSize)); |
| 420 // __ srl(a0, a3, kSmiTagSize); |
| 421 // |
| 422 //// __ break_(0x04205); |
| 423 // // TODO(MIPS.4): Optimize 'Copy args and receiver to the expression stack.' |
| 424 // // Copy arguments and receiver to the expression stack. |
| 425 // // a0: number of arguments |
| 426 // // a1: constructor function |
| 427 // // a2: address of last argument (caller sp) |
| 428 // // a3: number of arguments (smi-tagged) |
| 429 // // sp[0]: receiver |
| 430 // // sp[1]: constructor function |
| 431 // // sp[2]: receiver |
| 432 // // sp[3]: constructor function |
| 433 // // sp[4]: number of arguments (smi-tagged) |
| 434 // Label loop, entry; |
| 435 // __ b(&entry); |
| 436 // __ bind(&loop); // LOOP |
| 437 // __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); |
| 438 // __ add(t0, t0, Operand(a2)); |
| 439 // __ lw(ip, MemOperand(t0)); |
| 440 // __ push(ip); |
| 441 // __ bind(&entry); // ENTRY |
| 442 // __ addiu(a3, a3, Operand(-2)); |
| 443 // __ bcond(greater_equal, &loop, a3, Operand(zero_reg)); |
| 444 // __ nop(); |
| 445 // |
| 446 // // Call the function. |
| 447 // // a0: number of arguments |
| 448 // // a1: constructor function |
| 449 // ParameterCount actual(a0); |
| 450 // __ InvokeFunction(a1, actual, CALL_FUNCTION, false); |
| 451 // __ nop(); // NOP_ADDED |
| 452 // |
| 453 // // Pop the function from the stack. |
| 454 // // sp[0]: constructor function |
| 455 // // sp[2]: receiver |
| 456 // // sp[3]: constructor function |
| 457 // // sp[4]: number of arguments (smi-tagged) |
| 458 // __ pop(); |
| 459 // |
| 460 // // Restore context from the frame. |
| 461 // // v0: result |
| 462 // // sp[0]: receiver |
| 463 // // sp[1]: constructor function |
| 464 // // sp[2]: number of arguments (smi-tagged) |
| 465 //// __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 466 // __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 467 // |
| 468 // // If the result is an object (in the ECMA sense), we should get rid |
| 469 // // of the receiver and use the result; see ECMA-262 section 13.2.2-7 |
| 470 // // on page 74. |
| 471 // Label use_receiver, exit; |
| 472 // |
| 473 // // If the result is a smi, it is *not* an object in the ECMA sense. |
| 474 // // v0: result |
| 475 // // sp[0]: receiver (newly allocated object) |
| 476 // // sp[1]: constructor function |
| 477 // // sp[2]: number of arguments (smi-tagged) |
| 478 //// __ tst(r0, Operand(kSmiTagMask)); |
| 479 //// __ b(eq, &use_receiver); |
| 480 // __ andi(t0, v0, Operand(kSmiTagMask)); |
| 481 // __ beq(t0, zero_reg, &use_receiver); |
| 482 // __ nop(); // NOP_ADDED |
| 483 // |
| 484 // |
| 485 // // If the type of the result (stored in its map) is less than |
| 486 // // FIRST_JS_OBJECT_TYPE, it is not an object in the ECMA sense. |
| 487 //// __ CompareObjectType(r0, r3, r3, FIRST_JS_OBJECT_TYPE); |
| 488 //// __ b(ge, &exit); |
| 489 // __ GetObjectType(v0, a3, a3); |
| 490 // __ bcond(greater_equal, &exit, a3, Operand(FIRST_JS_OBJECT_TYPE)); |
| 491 // __ nop(); // NOP_ADDED |
| 492 // |
| 493 // // Throw away the result of the constructor invocation and use the |
| 494 // // on-stack receiver as the result. |
| 495 // __ bind(&use_receiver); |
| 496 //// __ ldr(r0, MemOperand(sp)); |
| 497 // __ lw(v0, MemOperand(sp)); |
| 498 // |
| 499 // // Remove receiver from the stack, remove caller arguments, and |
| 500 // // return. |
| 501 // __ bind(&exit); |
| 502 // // v0: result |
| 503 // // sp[0]: receiver (newly allocated object) |
| 504 // // sp[1]: constructor function |
| 505 // // sp[2]: number of arguments (smi-tagged) |
| 506 //// __ ldr(r1, MemOperand(sp, 2 * kPointerSize)); |
| 507 //// __ LeaveConstructFrame(); |
| 508 //// __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); |
| 509 //// __ add(sp, sp, Operand(kPointerSize)); |
| 510 //// __ IncrementCounter(&Counters::constructed_objects, 1, r1, r2); |
| 511 //// __ Jump(lr); |
| 512 // __ lw(a1, MemOperand(sp, 2 * kPointerSize)); |
| 513 // __ LeaveConstructFrame(); |
| 514 // __ sll(t0, a1, kPointerSizeLog2 - 1); |
| 515 // __ add(sp, sp, t0); |
| 516 // __ add(sp, sp, Operand(kPointerSize)); |
| 517 // __ IncrementCounter(&Counters::constructed_objects, 1, a1, a2); |
| 518 // __ Jump(ra); |
| 519 // __ nop(); // NOP_ADDED |
| 520 } |
| 521 |
| 522 |
| 523 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
| 524 bool is_construct) { |
| 525 UNIMPLEMENTED_(); |
| 526 // // Called from JSEntryStub::GenerateBody |
| 527 // // a0: code entry |
| 528 // // a1: function |
| 529 // // a2: receiver |
| 530 // // a3: argc |
| 531 // // s0: argv |
| 532 // |
| 533 // |
| 534 // // Clear the context before we push it when entering the JS frame. |
| 535 // __ li(cp, Operand(0)); |
| 536 // |
| 537 // // Enter an internal frame. |
| 538 // __ EnterInternalFrame(); |
| 539 // |
| 540 // // Set up the context from the function argument. |
| 541 // __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
| 542 // |
| 543 // // Set up the roots register. |
| 544 // ExternalReference roots_address = ExternalReference::roots_address(); |
| 545 // __ li(s4, Operand(roots_address)); |
| 546 // |
| 547 // // Push the function and the receiver onto the stack. |
| 548 // __ multi_push(a1.bit() | a2.bit()); |
| 549 // |
| 550 // |
| 551 // // Copy arguments to the stack in a loop. |
| 552 // // a1: function |
| 553 // // a3: argc |
| 554 // // s0: argv, ie points to first arg |
| 555 // Label loop, entry; |
| 556 // __ sll(t0, a3, kPointerSizeLog2); |
| 557 // __ add(a2, s0, t0); |
| 558 // // a2 points past last arg. |
| 559 // __ b(&entry); |
| 560 // __ nop(); // NOP_ADDED |
| 561 // __ bind(&loop); |
| 562 // __ lw(a0, MemOperand(s0)); // read next parameter |
| 563 // __ addiu(s0, Operand(kPointerSize)); |
| 564 // __ lw(a0, MemOperand(a0)); // dereference handle |
| 565 // __ push(a0); // push parameter. |
| 566 // __ bind(&entry); |
| 567 // __ bcond(ne, &loop, s0, Operand(a2)); |
| 568 // __ nop(); // NOP_ADDED |
| 569 // |
| 570 // // Initialize all JavaScript callee-saved registers, since they will be seen |
| 571 // // by the garbage collector as part of handlers. |
| 572 // __ LoadRoot(t4, Heap::kUndefinedValueRootIndex); |
| 573 // __ mov(s1, t4); |
| 574 // __ mov(s2, t4); |
| 575 // __ mov(s3, t4); // s3 is used for sp temp save. |
| 576 //// __ mov(s4, s4); // s4 holds the root address. Do not init. |
| 577 // __ mov(s5, t4); // Used for condition evaluation. |
| 578 // __ mov(s6, t4); // Used for condition evaluation. |
| 579 //// __ mov(s7, s7); // s7 is cp. Do not init. |
| 580 // |
| 581 // // Invoke the code and pass argc as a0. |
| 582 // __ mov(a0, a3); |
| 583 // if (is_construct) { |
| 584 // __ break_(0x594); |
| 585 // // We don't need arguments slots since we jump to our code. |
| 586 // __ Call(Handle<Code>(Builtins::builtin(Builtins::JSConstructCall)), |
| 587 // RelocInfo::CODE_TARGET); |
| 588 // __ nop(); |
| 589 // } else { |
| 590 // ParameterCount actual(a0); |
| 591 // __ InvokeFunction(a1, actual, CALL_FUNCTION, false); |
| 592 // // Args slots are allocated in InvokeFunction. |
| 593 // } |
| 594 // |
| 595 // // Exit the JS frame and remove the parameters (except function), and return
. |
| 596 // // Respect ABI stack constraint. |
| 597 // __ LeaveInternalFrame(); |
| 598 // |
| 599 // __ Jump(ra); |
| 600 // __ nop(); // NOP_ADDED |
| 601 // |
| 602 // // v0: result |
| 603 // |
| 604 } |
| 605 |
| 606 |
| 607 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { |
| 608 Generate_JSEntryTrampolineHelper(masm, false); |
| 609 } |
| 610 |
| 611 |
| 612 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
| 613 Generate_JSEntryTrampolineHelper(masm, true); |
| 614 } |
| 615 |
| 616 |
| 617 void Builtins::Generate_FunctionCall(MacroAssembler* masm) { |
| 618 UNIMPLEMENTED_(); |
| 619 __ break_(0x619); |
| 620 // __ break_(0x12345); |
| 621 // // 1. Make sure we have at least one argument. |
| 622 // // r0: actual number of argument |
| 623 // { Label done; |
| 624 // __ tst(r0, Operand(r0)); |
| 625 // __ b(ne, &done); |
| 626 // __ LoadRoot(r2, Heap::kUndefinedValueRootIndex); |
| 627 // __ push(r2); |
| 628 // __ add(r0, r0, Operand(1)); |
| 629 // __ bind(&done); |
| 630 // } |
| 631 // |
| 632 // // 2. Get the function to call from the stack. |
| 633 // // r0: actual number of argument |
| 634 // { Label done, non_function, function; |
| 635 // __ ldr(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); |
| 636 // __ tst(r1, Operand(kSmiTagMask)); |
| 637 // __ b(eq, &non_function); |
| 638 // __ CompareObjectType(r1, r2, r2, JS_FUNCTION_TYPE); |
| 639 // __ b(eq, &function); |
| 640 // |
| 641 // // Non-function called: Clear the function to force exception. |
| 642 // __ bind(&non_function); |
| 643 // __ mov(r1, Operand(0)); |
| 644 // __ b(&done); |
| 645 // |
| 646 // // Change the context eagerly because it will be used below to get the |
| 647 // // right global object. |
| 648 // __ bind(&function); |
| 649 // __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
| 650 // |
| 651 // __ bind(&done); |
| 652 // } |
| 653 // |
| 654 // // 3. Make sure first argument is an object; convert if necessary. |
| 655 // // r0: actual number of arguments |
| 656 // // r1: function |
| 657 // { Label call_to_object, use_global_receiver, patch_receiver, done; |
| 658 // __ add(r2, sp, Operand(r0, LSL, kPointerSizeLog2)); |
| 659 // __ ldr(r2, MemOperand(r2, -kPointerSize)); |
| 660 // |
| 661 // // r0: actual number of arguments |
| 662 // // r1: function |
| 663 // // r2: first argument |
| 664 // __ tst(r2, Operand(kSmiTagMask)); |
| 665 // __ b(eq, &call_to_object); |
| 666 // |
| 667 // __ LoadRoot(r3, Heap::kNullValueRootIndex); |
| 668 // __ cmp(r2, r3); |
| 669 // __ b(eq, &use_global_receiver); |
| 670 // __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
| 671 // __ cmp(r2, r3); |
| 672 // __ b(eq, &use_global_receiver); |
| 673 // |
| 674 // __ CompareObjectType(r2, r3, r3, FIRST_JS_OBJECT_TYPE); |
| 675 // __ b(lt, &call_to_object); |
| 676 // __ cmp(r3, Operand(LAST_JS_OBJECT_TYPE)); |
| 677 // __ b(le, &done); |
| 678 // |
| 679 // __ bind(&call_to_object); |
| 680 // __ EnterInternalFrame(); |
| 681 // |
| 682 // // Store number of arguments and function across the call into the runtime
. |
| 683 // __ mov(r0, Operand(r0, LSL, kSmiTagSize)); |
| 684 // __ push(r0); |
| 685 // __ push(r1); |
| 686 // |
| 687 // __ push(r2); |
| 688 // __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_JS); |
| 689 // __ mov(r2, r0); |
| 690 // |
| 691 // // Restore number of arguments and function. |
| 692 // __ pop(r1); |
| 693 // __ pop(r0); |
| 694 // __ mov(r0, Operand(r0, ASR, kSmiTagSize)); |
| 695 // |
| 696 // __ LeaveInternalFrame(); |
| 697 // __ b(&patch_receiver); |
| 698 // |
| 699 // // Use the global receiver object from the called function as the receiver
. |
| 700 // __ bind(&use_global_receiver); |
| 701 // const int kGlobalIndex = |
| 702 // Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize; |
| 703 // __ ldr(r2, FieldMemOperand(cp, kGlobalIndex)); |
| 704 // __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset)); |
| 705 // |
| 706 // __ bind(&patch_receiver); |
| 707 // __ add(r3, sp, Operand(r0, LSL, kPointerSizeLog2)); |
| 708 // __ str(r2, MemOperand(r3, -kPointerSize)); |
| 709 // |
| 710 // __ bind(&done); |
| 711 // } |
| 712 // |
| 713 // // 4. Shift stuff one slot down the stack |
| 714 // // r0: actual number of arguments (including call() receiver) |
| 715 // // r1: function |
| 716 // { Label loop; |
| 717 // // Calculate the copy start address (destination). Copy end address is sp. |
| 718 // __ add(r2, sp, Operand(r0, LSL, kPointerSizeLog2)); |
| 719 // __ add(r2, r2, Operand(kPointerSize)); // copy receiver too |
| 720 // |
| 721 // __ bind(&loop); |
| 722 // __ ldr(ip, MemOperand(r2, -kPointerSize)); |
| 723 // __ str(ip, MemOperand(r2)); |
| 724 // __ sub(r2, r2, Operand(kPointerSize)); |
| 725 // __ cmp(r2, sp); |
| 726 // __ b(ne, &loop); |
| 727 // } |
| 728 // |
| 729 // // 5. Adjust the actual number of arguments and remove the top element. |
| 730 // // r0: actual number of arguments (including call() receiver) |
| 731 // // r1: function |
| 732 // __ sub(r0, r0, Operand(1)); |
| 733 // __ add(sp, sp, Operand(kPointerSize)); |
| 734 // |
| 735 // // 6. Get the code for the function or the non-function builtin. |
| 736 // // If number of expected arguments matches, then call. Otherwise restart |
| 737 // // the arguments adaptor stub. |
| 738 // // r0: actual number of arguments |
| 739 // // r1: function |
| 740 // { Label invoke; |
| 741 // __ tst(r1, r1); |
| 742 // __ b(ne, &invoke); |
| 743 // __ mov(r2, Operand(0)); // expected arguments is 0 for CALL_NON_FUNCTION |
| 744 // __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); |
| 745 // __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), |
| 746 // RelocInfo::CODE_TARGET); |
| 747 // |
| 748 // __ bind(&invoke); |
| 749 // __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
| 750 // __ ldr(r2, |
| 751 // FieldMemOperand(r3, |
| 752 // SharedFunctionInfo::kFormalParameterCountOffset)); |
| 753 // __ ldr(r3, |
| 754 // MemOperand(r3, SharedFunctionInfo::kCodeOffset - kHeapObjectTag)); |
| 755 // __ add(r3, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 756 // __ cmp(r2, r0); // Check formal and actual parameter counts. |
| 757 // __ Jump(Handle<Code>(builtin(ArgumentsAdaptorTrampoline)), |
| 758 // RelocInfo::CODE_TARGET, ne); |
| 759 // |
| 760 // // 7. Jump to the code in r3 without checking arguments. |
| 761 // ParameterCount expected(0); |
| 762 // __ InvokeCode(r3, expected, expected, JUMP_FUNCTION); |
| 763 // } |
| 764 } |
| 765 |
| 766 |
| 767 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
| 768 UNIMPLEMENTED_(); |
| 769 __ nop(); |
| 770 __ break_(0x77712); |
| 771 // const int kIndexOffset = -5 * kPointerSize; |
| 772 // const int kLimitOffset = -4 * kPointerSize; |
| 773 // const int kArgsOffset = 2 * kPointerSize; |
| 774 // const int kRecvOffset = 3 * kPointerSize; |
| 775 // const int kFunctionOffset = 4 * kPointerSize; |
| 776 // |
| 777 // __ EnterInternalFrame(); |
| 778 // |
| 779 // __ ldr(r0, MemOperand(fp, kFunctionOffset)); // get the function |
| 780 // __ push(r0); |
| 781 // __ ldr(r0, MemOperand(fp, kArgsOffset)); // get the args array |
| 782 // __ push(r0); |
| 783 // __ InvokeBuiltin(Builtins::APPLY_PREPARE, CALL_JS); |
| 784 // |
| 785 // Label no_preemption, retry_preemption; |
| 786 // __ bind(&retry_preemption); |
| 787 // ExternalReference stack_guard_limit_address = |
| 788 // ExternalReference::address_of_stack_guard_limit(); |
| 789 // __ mov(r2, Operand(stack_guard_limit_address)); |
| 790 // __ ldr(r2, MemOperand(r2)); |
| 791 // __ cmp(sp, r2); |
| 792 // __ b(hi, &no_preemption); |
| 793 // |
| 794 // // We have encountered a preemption or stack overflow already before we push |
| 795 // // the array contents. Save r0 which is the Smi-tagged length of the array. |
| 796 // __ push(r0); |
| 797 // |
| 798 // // Runtime routines expect at least one argument, so give it a Smi. |
| 799 // __ mov(r0, Operand(Smi::FromInt(0))); |
| 800 // __ push(r0); |
| 801 // __ CallRuntime(Runtime::kStackGuard, 1); |
| 802 // |
| 803 // // Since we returned, it wasn't a stack overflow. Restore r0 and try again. |
| 804 // __ pop(r0); |
| 805 // __ b(&retry_preemption); |
| 806 // |
| 807 // __ bind(&no_preemption); |
| 808 // |
| 809 // // Eagerly check for stack-overflow before starting to push the arguments. |
| 810 // // r0: number of arguments. |
| 811 // // r2: stack limit. |
| 812 // Label okay; |
| 813 // __ sub(r2, sp, r2); |
| 814 // |
| 815 // __ cmp(r2, Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize)); |
| 816 // __ b(hi, &okay); |
| 817 // |
| 818 // // Out of stack space. |
| 819 // __ ldr(r1, MemOperand(fp, kFunctionOffset)); |
| 820 // __ push(r1); |
| 821 // __ push(r0); |
| 822 // __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_JS); |
| 823 // |
| 824 // // Push current limit and index. |
| 825 // __ bind(&okay); |
| 826 // __ push(r0); // limit |
| 827 // __ mov(r1, Operand(0)); // initial index |
| 828 // __ push(r1); |
| 829 // |
| 830 // // Change context eagerly to get the right global object if necessary. |
| 831 // __ ldr(r0, MemOperand(fp, kFunctionOffset)); |
| 832 // __ ldr(cp, FieldMemOperand(r0, JSFunction::kContextOffset)); |
| 833 // |
| 834 // // Compute the receiver. |
| 835 // Label call_to_object, use_global_receiver, push_receiver; |
| 836 // __ ldr(r0, MemOperand(fp, kRecvOffset)); |
| 837 // __ tst(r0, Operand(kSmiTagMask)); |
| 838 // __ b(eq, &call_to_object); |
| 839 // __ LoadRoot(r1, Heap::kNullValueRootIndex); |
| 840 // __ cmp(r0, r1); |
| 841 // __ b(eq, &use_global_receiver); |
| 842 // __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); |
| 843 // __ cmp(r0, r1); |
| 844 // __ b(eq, &use_global_receiver); |
| 845 // |
| 846 // // Check if the receiver is already a JavaScript object. |
| 847 // // r0: receiver |
| 848 // __ CompareObjectType(r0, r1, r1, FIRST_JS_OBJECT_TYPE); |
| 849 // __ b(lt, &call_to_object); |
| 850 // __ cmp(r1, Operand(LAST_JS_OBJECT_TYPE)); |
| 851 // __ b(le, &push_receiver); |
| 852 // |
| 853 // // Convert the receiver to a regular object. |
| 854 // // r0: receiver |
| 855 // __ bind(&call_to_object); |
| 856 // __ push(r0); |
| 857 // __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_JS); |
| 858 // __ b(&push_receiver); |
| 859 // |
| 860 // // Use the current global receiver object as the receiver. |
| 861 // __ bind(&use_global_receiver); |
| 862 // const int kGlobalOffset = |
| 863 // Context::kHeaderSize + Context::GLOBAL_INDEX * kPointerSize; |
| 864 // __ ldr(r0, FieldMemOperand(cp, kGlobalOffset)); |
| 865 // __ ldr(r0, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset)); |
| 866 // |
| 867 // // Push the receiver. |
| 868 // // r0: receiver |
| 869 // __ bind(&push_receiver); |
| 870 // __ push(r0); |
| 871 // |
| 872 // // Copy all arguments from the array to the stack. |
| 873 // Label entry, loop; |
| 874 // __ ldr(r0, MemOperand(fp, kIndexOffset)); |
| 875 // __ b(&entry); |
| 876 // |
| 877 // // Load the current argument from the arguments array and push it to the |
| 878 // // stack. |
| 879 // // r0: current argument index |
| 880 // __ bind(&loop); |
| 881 // __ ldr(r1, MemOperand(fp, kArgsOffset)); |
| 882 // __ push(r1); |
| 883 // __ push(r0); |
| 884 // |
| 885 // // Call the runtime to access the property in the arguments array. |
| 886 // __ CallRuntime(Runtime::kGetProperty, 2); |
| 887 // __ push(r0); |
| 888 // |
| 889 // // Use inline caching to access the arguments. |
| 890 // __ ldr(r0, MemOperand(fp, kIndexOffset)); |
| 891 // __ add(r0, r0, Operand(1 << kSmiTagSize)); |
| 892 // __ str(r0, MemOperand(fp, kIndexOffset)); |
| 893 // |
| 894 // // Test if the copy loop has finished copying all the elements from the |
| 895 // // arguments object. |
| 896 // __ bind(&entry); |
| 897 // __ ldr(r1, MemOperand(fp, kLimitOffset)); |
| 898 // __ cmp(r0, r1); |
| 899 // __ b(ne, &loop); |
| 900 // |
| 901 // // Invoke the function. |
| 902 // ParameterCount actual(r0); |
| 903 // __ mov(r0, Operand(r0, ASR, kSmiTagSize)); |
| 904 // __ ldr(r1, MemOperand(fp, kFunctionOffset)); |
| 905 // __ InvokeFunction(r1, actual, CALL_FUNCTION); |
| 906 // |
| 907 // // Tear down the internal frame and remove function, receiver and args. |
| 908 // __ LeaveInternalFrame(); |
| 909 // __ add(sp, sp, Operand(3 * kPointerSize)); |
| 910 // __ Jump(lr); |
| 911 } |
| 912 |
| 913 //static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
| 914 // UNIMPLEMENTED_(); |
| 915 //// __ mov(r0, Operand(r0, LSL, kSmiTagSize)); |
| 916 //// __ mov(r4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 917 //// __ stm(db_w, sp, r0.bit() | r1.bit() | r4.bit() | fp.bit() | lr.bit()); |
| 918 //// __ add(fp, sp, Operand(3 * kPointerSize)); |
| 919 // __ sll(a0, a0, kSmiTagSize); |
| 920 // __ li(t0, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 921 // __ multi_push_reversed(a0.bit() | a1.bit() | t0.bit() | fp.bit() | ra.bit())
; |
| 922 // __ add(fp, sp, Operand(3 * kPointerSize)); |
| 923 //} |
| 924 |
| 925 |
| 926 //static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { |
| 927 // UNIMPLEMENTED_(); |
| 928 // // ----------- S t a t e ------------- |
| 929 // // -- r0 : result being passed through |
| 930 // // ----------------------------------- |
| 931 // // Get the number of arguments passed (as a smi), tear down the frame and |
| 932 // // then tear down the parameters. |
| 933 //// __ ldr(r1, MemOperand(fp, -3 * kPointerSize)); |
| 934 //// __ mov(sp, fp); |
| 935 //// __ ldm(ia_w, sp, fp.bit() | lr.bit()); |
| 936 //// __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - kSmiTagSize)); |
| 937 //// __ add(sp, sp, Operand(kPointerSize)); // adjust for receiver |
| 938 // __ lw(a1, MemOperand(fp, -3 * kPointerSize)); |
| 939 // __ mov(sp, fp); |
| 940 // __ multi_pop_reversed(fp.bit() | ra.bit()); |
| 941 // __ sll(ip, a1, kPointerSizeLog2 - kSmiTagSize); |
| 942 //// __ addiu(ip, ip, StandardFrameConstants::kRArgsSlotsSize); |
| 943 // __ addu(sp, sp, ip); |
| 944 // __ addiu(sp, sp, Operand(kPointerSize)); // adjust for receiver |
| 945 //} |
| 946 |
| 947 |
| 948 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
| 949 UNIMPLEMENTED_(); |
| 950 // // ----------- S t a t e ------------- |
| 951 // // -- r0->a0 : actual number of arguments |
| 952 // // -- r1->a1 : function (passed through to callee) |
| 953 // // -- r2->a2 : expected number of arguments |
| 954 // // -- r3->a3 : code entry to call |
| 955 //// // -- v1 : use args slots (==0) or not (!=0) |
| 956 // // ----------------------------------- |
| 957 // |
| 958 // Label invoke, dont_adapt_arguments; |
| 959 // |
| 960 // Label enough, too_few; |
| 961 //// __ cmp(r0, Operand(r2)); |
| 962 //// __ b(lt, &too_few); |
| 963 //// __ cmp(r2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
| 964 //// __ b(eq, &dont_adapt_arguments); |
| 965 // __ bcond(less, &too_few, a0, Operand(a2)); |
| 966 // __ nop(); // NOP_ADDED |
| 967 // __ bcond(eq, &dont_adapt_arguments, a2, Operand(SharedFunctionInfo::kDontAda
ptArgumentsSentinel)); |
| 968 // __ nop(); // NOP_ADDED |
| 969 // |
| 970 // { // Enough parameters: actual >= expected |
| 971 // __ bind(&enough); |
| 972 // EnterArgumentsAdaptorFrame(masm); |
| 973 // |
| 974 // // Calculate copy start address into r0 and copy end address into r2. |
| 975 // // r0: actual number of arguments as a smi |
| 976 // // r1: function |
| 977 // // r2: expected number of arguments |
| 978 // // r3: code entry to call |
| 979 //// __ add(r0, fp, Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize)); |
| 980 // // adjust for return address and receiver |
| 981 //// __ add(r0, r0, Operand(2 * kPointerSize)); |
| 982 //// __ sub(r2, r0, Operand(r2, LSL, kPointerSizeLog2)); |
| 983 // __ sll(a0, a0, kPointerSizeLog2 - kSmiTagSize); |
| 984 // __ addu(a0, a0, fp); |
| 985 // // adjust for return address and receiver |
| 986 // __ addu(a0, a0, Operand(2 * kPointerSize)); |
| 987 // __ sll(a2, a2, kPointerSizeLog2); |
| 988 //// __ break_(0x11175); |
| 989 // __ subu(a2, a0, Operand(a2)); |
| 990 // |
| 991 // // Copy the arguments (including the receiver) to the new stack frame. |
| 992 // // r0: copy start address |
| 993 // // r1: function |
| 994 // // r2: copy end address |
| 995 // // r3: code entry to call |
| 996 // |
| 997 // Label copy; |
| 998 // __ bind(©); |
| 999 //// __ ldr(ip, MemOperand(r0, 0)); |
| 1000 //// __ push(ip); |
| 1001 //// __ cmp(r0, r2); // Compare before moving to next argument. |
| 1002 //// __ sub(r0, r0, Operand(kPointerSize)); |
| 1003 //// __ b(ne, ©); |
| 1004 // __ lw(ip, MemOperand(a0, 0)); |
| 1005 // __ push(ip); |
| 1006 // __ bcond(ne, ©, a0, Operand(a2)); |
| 1007 // __ addiu(a0, a0, Operand(-kPointerSize)); |
| 1008 // |
| 1009 //// __ b(&invoke); |
| 1010 // __ b(&invoke); |
| 1011 // __ nop(); |
| 1012 // } |
| 1013 // |
| 1014 // { // Too few parameters: Actual < expected |
| 1015 // __ bind(&too_few); |
| 1016 // EnterArgumentsAdaptorFrame(masm); |
| 1017 // |
| 1018 // // Calculate copy start address into r0 and copy end address is fp. |
| 1019 // // r0: actual number of arguments as a smi |
| 1020 // // r1: function |
| 1021 // // r2: expected number of arguments |
| 1022 // // r3: code entry to call |
| 1023 //// __ add(r0, fp, Operand(r0, LSL, kPointerSizeLog2 - kSmiTagSize)); |
| 1024 // __ sll(a0, a0, kPointerSizeLog2 - kSmiTagSize); |
| 1025 // __ addu(a0, a0, fp); |
| 1026 // |
| 1027 // // Copy the arguments (including the receiver) to the new stack frame. |
| 1028 // // r0: copy start address |
| 1029 // // r1: function |
| 1030 // // r2: expected number of arguments |
| 1031 // // r3: code entry to call |
| 1032 // Label copy; |
| 1033 // __ bind(©); |
| 1034 // // Adjust load for return address and receiver. |
| 1035 //// __ ldr(ip, MemOperand(r0, 2 * kPointerSize)); |
| 1036 //// __ push(ip); |
| 1037 //// __ cmp(r0, fp); // Compare before moving to next argument. |
| 1038 //// __ sub(r0, r0, Operand(kPointerSize)); |
| 1039 //// __ b(ne, ©); |
| 1040 // __ lw(ip, MemOperand(a0, 2 * kPointerSize)); |
| 1041 // __ push(ip); |
| 1042 // __ bcond(ne, ©, a0, Operand(fp)); |
| 1043 // __ addiu(a0, a0, Operand(-kPointerSize)); |
| 1044 // |
| 1045 // // Fill the remaining expected arguments with undefined. |
| 1046 // // r1: function |
| 1047 // // r2: expected number of arguments |
| 1048 // // r3: code entry to call |
| 1049 // __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); |
| 1050 //// __ sub(r2, fp, Operand(r2, LSL, kPointerSizeLog2)); |
| 1051 //// __ sub(r2, r2, Operand(4 * kPointerSize)); // Adjust for frame. |
| 1052 // __ sll(a2, a2, kPointerSizeLog2); |
| 1053 // __ subu(a2, fp, Operand(a2)); |
| 1054 // __ addiu(a2, a2, Operand(-4 * kPointerSize)); // Adjust for frame. |
| 1055 // |
| 1056 // Label fill; |
| 1057 // __ bind(&fill); |
| 1058 // __ push(ip); |
| 1059 //// __ cmp(sp, r2); |
| 1060 //// __ b(ne, &fill); |
| 1061 // __ bcond(ne, &fill, sp, Operand(a2)); |
| 1062 // __ nop(); // NOP_ADDED |
| 1063 // } |
| 1064 // |
| 1065 // // Call the entry point. |
| 1066 // __ bind(&invoke); |
| 1067 // |
| 1068 // // Check if we need args slots |
| 1069 // // We don't restore sp on return because LeaveArgumentsAdaptorFrame does the |
| 1070 // // job for us. |
| 1071 //// __ bne(v1, zero_reg, 3); |
| 1072 //// __ nop(); |
| 1073 ////// __ break_(0x1076); |
| 1074 //// __ addiu(sp, sp, -StandardFrameConstants::kRArgsSlotsSize); |
| 1075 // |
| 1076 //// __ Call(r3); |
| 1077 // __ Call(a3); |
| 1078 // __ nop(); // NOP_ADDED |
| 1079 // |
| 1080 // // We don't restore because LeaveArgumentsAdaptorFrame does it. |
| 1081 //// __ addiu(sp, sp, x-StandardFrameConstants::kRArgsSlotsSize); |
| 1082 // |
| 1083 // // Exit frame and return. |
| 1084 // LeaveArgumentsAdaptorFrame(masm); |
| 1085 //// __ Jump(lr); |
| 1086 // __ Jump(ra); |
| 1087 // __ nop(); // NOP_ADDED |
| 1088 // |
| 1089 // |
| 1090 // // ------------------------------------------- |
| 1091 // // Dont adapt arguments. |
| 1092 // // ------------------------------------------- |
| 1093 // __ bind(&dont_adapt_arguments); |
| 1094 //// __ Jump(r3); |
| 1095 // __ Jump(a3); |
| 1096 // __ nop(); // NOP_ADDED |
| 1097 } |
| 1098 |
| 1099 |
| 1100 #undef __ |
| 1101 |
| 1102 } } // namespace v8::internal |
| OLD | NEW |