OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 return Failure::InternalError(); | 234 return Failure::InternalError(); |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 | 238 |
239 Object* CallStubCompiler::CompileCallGlobal(JSObject* object, | 239 Object* CallStubCompiler::CompileCallGlobal(JSObject* object, |
240 GlobalObject* holder, | 240 GlobalObject* holder, |
241 JSGlobalPropertyCell* cell, | 241 JSGlobalPropertyCell* cell, |
242 JSFunction* function, | 242 JSFunction* function, |
243 String* name) { | 243 String* name) { |
244 // TODO(X64): Implement a real stub. | 244 // ----------- S t a t e ------------- |
245 return Failure::InternalError(); | 245 // ----------------------------------- |
| 246 // rsp[0] return address |
| 247 // rsp[8] argument argc |
| 248 // rsp[16] argument argc - 1 |
| 249 // ... |
| 250 // rsp[argc * 8] argument 1 |
| 251 // rsp[(argc + 1) * 8] argument 0 = receiver |
| 252 // rsp[(argc + 2) * 8] function name |
| 253 Label miss; |
| 254 |
| 255 __ IncrementCounter(&Counters::call_global_inline, 1); |
| 256 |
| 257 // Get the number of arguments. |
| 258 const int argc = arguments().immediate(); |
| 259 |
| 260 // Get the receiver from the stack. |
| 261 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); |
| 262 |
| 263 // If the object is the holder then we know that it's a global |
| 264 // object which can only happen for contextual calls. In this case, |
| 265 // the receiver cannot be a smi. |
| 266 if (object != holder) { |
| 267 __ testl(rdx, Immediate(kSmiTagMask)); |
| 268 __ j(zero, &miss); |
| 269 } |
| 270 |
| 271 // Check that the maps haven't changed. |
| 272 CheckPrototypes(object, rdx, holder, rbx, rcx, name, &miss); |
| 273 |
| 274 // Get the value from the cell. |
| 275 __ Move(rdi, Handle<JSGlobalPropertyCell>(cell)); |
| 276 __ movq(rdi, FieldOperand(rdi, JSGlobalPropertyCell::kValueOffset)); |
| 277 |
| 278 // Check that the cell contains the same function. |
| 279 __ Cmp(rdi, Handle<JSFunction>(function)); |
| 280 __ j(not_equal, &miss); |
| 281 |
| 282 // Patch the receiver on the stack with the global proxy. |
| 283 if (object->IsGlobalObject()) { |
| 284 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); |
| 285 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); |
| 286 } |
| 287 |
| 288 // Setup the context (function already in edi). |
| 289 __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
| 290 |
| 291 // Jump to the cached code (tail call). |
| 292 ASSERT(function->is_compiled()); |
| 293 Handle<Code> code(function->code()); |
| 294 ParameterCount expected(function->shared()->formal_parameter_count()); |
| 295 __ InvokeCode(code, expected, arguments(), |
| 296 RelocInfo::CODE_TARGET, JUMP_FUNCTION); |
| 297 |
| 298 // Handle call cache miss. |
| 299 __ bind(&miss); |
| 300 __ DecrementCounter(&Counters::call_global_inline, 1); |
| 301 __ IncrementCounter(&Counters::call_global_inline_miss, 1); |
| 302 Handle<Code> ic = ComputeCallMiss(arguments().immediate()); |
| 303 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 304 |
| 305 // Return the generated code. |
| 306 return GetCode(NORMAL, name); |
246 } | 307 } |
247 | 308 |
248 | 309 |
249 Object* LoadStubCompiler::CompileLoadCallback(JSObject* a, | 310 Object* LoadStubCompiler::CompileLoadCallback(JSObject* a, |
250 JSObject* b, | 311 JSObject* b, |
251 AccessorInfo* c, | 312 AccessorInfo* c, |
252 String* d) { | 313 String* d) { |
253 UNIMPLEMENTED(); | 314 UNIMPLEMENTED(); |
254 return NULL; | 315 return NULL; |
255 } | 316 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 int offset = index * kPointerSize + FixedArray::kHeaderSize; | 485 int offset = index * kPointerSize + FixedArray::kHeaderSize; |
425 __ movq(dst, FieldOperand(src, JSObject::kPropertiesOffset)); | 486 __ movq(dst, FieldOperand(src, JSObject::kPropertiesOffset)); |
426 __ movq(dst, FieldOperand(dst, offset)); | 487 __ movq(dst, FieldOperand(dst, offset)); |
427 } | 488 } |
428 } | 489 } |
429 | 490 |
430 #undef __ | 491 #undef __ |
431 | 492 |
432 | 493 |
433 } } // namespace v8::internal | 494 } } // namespace v8::internal |
OLD | NEW |