| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 __ ldr(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); | 147 __ ldr(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 | 150 |
| 151 #undef __ | 151 #undef __ |
| 152 | 152 |
| 153 #define __ masm()-> | 153 #define __ masm()-> |
| 154 | 154 |
| 155 | 155 |
| 156 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { | 156 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { |
| 157 // ----------- S t a t e ------------- |
| 158 // -- r1: function |
| 159 // -- lr: return address |
| 160 // ----------------------------------- |
| 161 |
| 157 HandleScope scope; | 162 HandleScope scope; |
| 158 | 163 |
| 159 // Enter the JS frame but don't add additional arguments. | 164 // Enter an internal frame. |
| 160 __ EnterJSFrame(0); | 165 __ EnterInternalFrame(); |
| 161 | 166 |
| 162 // Push the function on the stack and call the runtime function. | 167 // Preserve the function. |
| 163 __ ldr(r0, MemOperand(pp, 0)); | 168 __ push(r1); |
| 164 __ push(r0); | 169 |
| 170 // Push the function on the stack as the argument to the runtime function. |
| 171 __ push(r1); |
| 165 __ CallRuntime(Runtime::kLazyCompile, 1); | 172 __ CallRuntime(Runtime::kLazyCompile, 1); |
| 166 | 173 |
| 167 // Move result to r1 and restore number of arguments. | 174 // Calculate the entry point. |
| 168 __ mov(r1, Operand(r0)); | 175 __ add(r2, r0, Operand(Code::kHeaderSize - kHeapObjectTag)); |
| 169 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kArgsLengthOffset)); | |
| 170 | 176 |
| 171 __ ExitJSFrame(DO_NOT_RETURN); | 177 // Restore saved function. |
| 178 __ pop(r1); |
| 179 |
| 180 // Tear down temporary frame. |
| 181 __ ExitInternalFrame(); |
| 172 | 182 |
| 173 // Do a tail-call of the compiled function. | 183 // Do a tail-call of the compiled function. |
| 174 __ add(r1, r1, Operand(Code::kHeaderSize - kHeapObjectTag)); | 184 __ Jump(r2); |
| 175 __ Jump(r1); | |
| 176 | 185 |
| 177 return GetCodeWithFlags(flags); | 186 return GetCodeWithFlags(flags); |
| 178 } | 187 } |
| 179 | 188 |
| 180 | 189 |
| 181 Object* CallStubCompiler::CompileCallField(Object* object, | 190 Object* CallStubCompiler::CompileCallField(Object* object, |
| 182 JSObject* holder, | 191 JSObject* holder, |
| 183 int index) { | 192 int index) { |
| 184 // ----------- S t a t e ------------- | 193 // ----------- S t a t e ------------- |
| 185 // -- lr: return address | 194 // -- lr: return address |
| 186 // ----------------------------------- | 195 // ----------------------------------- |
| 187 | 196 |
| 188 HandleScope scope; | 197 HandleScope scope; |
| 189 Label miss; | 198 Label miss; |
| 190 | 199 |
| 191 const int argc = arguments().immediate(); | 200 const int argc = arguments().immediate(); |
| 192 | 201 |
| 193 // Get the receiver of the function from the stack into r1. | 202 // Get the receiver of the function from the stack into r1. |
| 194 __ ldr(r1, MemOperand(sp, argc * kPointerSize)); | 203 __ ldr(r1, MemOperand(sp, argc * kPointerSize)); |
| 195 // Check that the receiver isn't a smi. | 204 // Check that the receiver isn't a smi. |
| 196 __ tst(r1, Operand(kSmiTagMask)); | 205 __ tst(r1, Operand(kSmiTagMask)); |
| 197 __ b(eq, &miss); | 206 __ b(eq, &miss); |
| 198 | 207 |
| 199 // Do the right check and compute the holder register. | 208 // Do the right check and compute the holder register. |
| 200 Register reg = | 209 Register reg = |
| 201 __ CheckMaps(JSObject::cast(object), r1, holder, r3, r2, &miss); | 210 __ CheckMaps(JSObject::cast(object), r1, holder, r3, r2, &miss); |
| 202 | 211 |
| 203 // Get the properties array of the holder and get the function from the field. | 212 // Get the properties array of the holder and get the function from the field. |
| 204 int offset = index * kPointerSize + Array::kHeaderSize; | 213 int offset = index * kPointerSize + Array::kHeaderSize; |
| 205 __ ldr(r3, FieldMemOperand(reg, JSObject::kPropertiesOffset)); | 214 __ ldr(r1, FieldMemOperand(reg, JSObject::kPropertiesOffset)); |
| 206 __ ldr(r3, FieldMemOperand(r3, offset)); | 215 __ ldr(r1, FieldMemOperand(r1, offset)); |
| 207 | 216 |
| 208 // Check that the function really is a function. | 217 // Check that the function really is a function. |
| 209 __ tst(r3, Operand(kSmiTagMask)); | 218 __ tst(r1, Operand(kSmiTagMask)); |
| 210 __ b(eq, &miss); | 219 __ b(eq, &miss); |
| 211 // Get the map. | 220 // Get the map. |
| 212 __ ldr(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); | 221 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); |
| 213 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); | 222 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); |
| 214 __ cmp(r2, Operand(JS_FUNCTION_TYPE)); | 223 __ cmp(r2, Operand(JS_FUNCTION_TYPE)); |
| 215 __ b(ne, &miss); | 224 __ b(ne, &miss); |
| 216 | 225 |
| 217 // TODO(1233523): remove r0 after changing Jump to InvokeCode | |
| 218 // Setup argument length register. | |
| 219 __ mov(r0, Operand(argc)); | |
| 220 // Patch the function on the stack; 1 ~ receiver. | 226 // Patch the function on the stack; 1 ~ receiver. |
| 221 __ str(r3, MemOperand(sp, (argc + 1) * kPointerSize)); | 227 __ str(r1, MemOperand(sp, (argc + 1) * kPointerSize)); |
| 222 | 228 |
| 223 // Setup the context and jump to the call code of the function (tail call). | 229 // Invoke the function. |
| 224 __ ldr(cp, FieldMemOperand(r3, JSFunction::kContextOffset)); | 230 __ InvokeFunction(r1, arguments(), JUMP_FUNCTION); |
| 225 __ ldr(r2, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset)); | |
| 226 __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kCodeOffset)); | |
| 227 __ add(r2, r2, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
| 228 __ Jump(r2); | |
| 229 | 231 |
| 230 // Handle call cache miss. | 232 // Handle call cache miss. |
| 231 __ bind(&miss); | 233 __ bind(&miss); |
| 232 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); | 234 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); |
| 233 __ Jump(ic, code_target); | 235 __ Jump(ic, code_target); |
| 234 | 236 |
| 235 // Return the generated code. | 237 // Return the generated code. |
| 236 return GetCode(FIELD); | 238 return GetCode(FIELD); |
| 237 } | 239 } |
| 238 | 240 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 __ ldr(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); | 325 __ ldr(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); |
| 324 __ cmp(r2, Operand(Factory::hash_table_map())); | 326 __ cmp(r2, Operand(Factory::hash_table_map())); |
| 325 __ b(eq, &miss); | 327 __ b(eq, &miss); |
| 326 break; | 328 break; |
| 327 | 329 |
| 328 default: | 330 default: |
| 329 UNREACHABLE(); | 331 UNREACHABLE(); |
| 330 } | 332 } |
| 331 | 333 |
| 332 // Get the function and setup the context. | 334 // Get the function and setup the context. |
| 333 __ mov(r3, Operand(Handle<JSFunction>(function))); | 335 __ mov(r1, Operand(Handle<JSFunction>(function))); |
| 334 __ ldr(cp, FieldMemOperand(r3, JSFunction::kContextOffset)); | 336 __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
| 335 | 337 |
| 336 // Patch the function on the stack; 1 ~ receiver. | 338 // Patch the function on the stack; 1 ~ receiver. |
| 337 __ str(r3, MemOperand(sp, (argc + 1) * kPointerSize)); | 339 __ str(r1, MemOperand(sp, (argc + 1) * kPointerSize)); |
| 338 | 340 |
| 339 // Jump to the cached code (tail call). | 341 // Jump to the cached code (tail call). |
| 340 Handle<Code> code(function->code()); | 342 Handle<Code> code(function->code()); |
| 341 ParameterCount expected(function->shared()->formal_parameter_count()); | 343 ParameterCount expected(function->shared()->formal_parameter_count()); |
| 342 __ InvokeCode(code, expected, arguments(), code_target, JUMP_FUNCTION); | 344 __ InvokeCode(code, expected, arguments(), code_target, JUMP_FUNCTION); |
| 343 | 345 |
| 344 // Handle call cache miss. | 346 // Handle call cache miss. |
| 345 __ bind(&miss); | 347 __ bind(&miss); |
| 346 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); | 348 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); |
| 347 __ Jump(ic, code_target); | 349 __ Jump(ic, code_target); |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 String* name) { | 788 String* name) { |
| 787 UNIMPLEMENTED(); | 789 UNIMPLEMENTED(); |
| 788 return Heap::undefined_value(); | 790 return Heap::undefined_value(); |
| 789 } | 791 } |
| 790 | 792 |
| 791 | 793 |
| 792 | 794 |
| 793 #undef __ | 795 #undef __ |
| 794 | 796 |
| 795 } } // namespace v8::internal | 797 } } // namespace v8::internal |
| OLD | NEW |