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 2285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2296 Reference property(this, node); | 2296 Reference property(this, node); |
2297 property.GetValue(typeof_state()); | 2297 property.GetValue(typeof_state()); |
2298 } | 2298 } |
2299 | 2299 |
2300 | 2300 |
2301 void CodeGenerator::VisitCall(Call* node) { | 2301 void CodeGenerator::VisitCall(Call* node) { |
2302 Comment cmnt(masm_, "[ Call"); | 2302 Comment cmnt(masm_, "[ Call"); |
2303 | 2303 |
2304 ZoneList<Expression*>* args = node->arguments(); | 2304 ZoneList<Expression*>* args = node->arguments(); |
2305 | 2305 |
2306 if (FLAG_debug_info) RecordStatementPosition(node); | 2306 RecordStatementPosition(node); |
2307 // Standard function call. | 2307 // Standard function call. |
2308 | 2308 |
2309 // Check if the function is a variable or a property. | 2309 // Check if the function is a variable or a property. |
2310 Expression* function = node->expression(); | 2310 Expression* function = node->expression(); |
2311 Variable* var = function->AsVariableProxy()->AsVariable(); | 2311 Variable* var = function->AsVariableProxy()->AsVariable(); |
2312 Property* property = function->AsProperty(); | 2312 Property* property = function->AsProperty(); |
2313 | 2313 |
2314 // ------------------------------------------------------------------------ | 2314 // ------------------------------------------------------------------------ |
2315 // Fast-case: Use inline caching. | 2315 // Fast-case: Use inline caching. |
2316 // --- | 2316 // --- |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2423 // Pass the global proxy as the receiver. | 2423 // Pass the global proxy as the receiver. |
2424 LoadGlobalReceiver(r0); | 2424 LoadGlobalReceiver(r0); |
2425 | 2425 |
2426 // Call the function. | 2426 // Call the function. |
2427 CallWithArguments(args, node->position()); | 2427 CallWithArguments(args, node->position()); |
2428 frame_->Push(r0); | 2428 frame_->Push(r0); |
2429 } | 2429 } |
2430 } | 2430 } |
2431 | 2431 |
2432 | 2432 |
2433 void CodeGenerator::VisitCallEval(CallEval* node) { | |
2434 Comment cmnt(masm_, "[ Call"); | |
Mads Ager (chromium)
2008/11/27 13:46:02
CallEval?
| |
2435 | |
2436 // In a call to eval, we first call %ResolvePossiblyDirectEval to resolve | |
2437 // the function we need to call and the receiver of the call. | |
2438 // Then we call the resolved function using the given arguments. | |
2439 | |
2440 ZoneList<Expression*>* args = node->arguments(); | |
2441 Expression* function = node->expression(); | |
2442 | |
2443 RecordStatementPosition(node); | |
2444 | |
2445 // Prepare stack for call to resolved function. | |
2446 Load(function); | |
2447 __ mov(r2, Operand(Factory::undefined_value())); | |
2448 __ push(r2); // Slot for receiver | |
2449 for (int i = 0; i < args->length(); i++) { | |
2450 Load(args->at(i)); | |
2451 } | |
2452 | |
2453 // Prepare stack for call to ResolvePossiblyDirectEval. | |
2454 __ ldr(r1, MemOperand(sp, args->length() * kPointerSize + kPointerSize)); | |
2455 __ push(r1); | |
2456 if (args->length() > 0) { | |
2457 __ ldr(r1, MemOperand(sp, args->length() * kPointerSize)); | |
2458 __ push(r1); | |
2459 } else { | |
2460 __ push(r2); | |
2461 } | |
2462 | |
2463 // Resolve the call. | |
2464 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 2); | |
2465 | |
2466 // Touch up stack with the right values for the function and the receiver. | |
2467 __ ldr(r1, FieldMemOperand(r0, FixedArray::kHeaderSize)); | |
2468 __ str(r1, MemOperand(sp, (args->length() + 1) * kPointerSize)); | |
2469 __ ldr(r1, FieldMemOperand(r0, FixedArray::kHeaderSize + kPointerSize)); | |
2470 __ str(r1, MemOperand(sp, args->length() * kPointerSize)); | |
2471 | |
2472 // Call the function. | |
2473 __ RecordPosition(node->position()); | |
2474 | |
2475 CallFunctionStub call_function(args->length()); | |
2476 __ CallStub(&call_function); | |
2477 | |
2478 __ ldr(cp, frame_->Context()); | |
2479 // Remove the function from the stack. | |
2480 frame_->Pop(); | |
2481 frame_->Push(r0); | |
2482 } | |
2483 | |
2484 | |
2433 void CodeGenerator::VisitCallNew(CallNew* node) { | 2485 void CodeGenerator::VisitCallNew(CallNew* node) { |
2434 Comment cmnt(masm_, "[ CallNew"); | 2486 Comment cmnt(masm_, "[ CallNew"); |
2435 | 2487 |
2436 // According to ECMA-262, section 11.2.2, page 44, the function | 2488 // According to ECMA-262, section 11.2.2, page 44, the function |
2437 // expression in new calls must be evaluated before the | 2489 // expression in new calls must be evaluated before the |
2438 // arguments. This is different from ordinary calls, where the | 2490 // arguments. This is different from ordinary calls, where the |
2439 // actual function to call is resolved after the arguments have been | 2491 // actual function to call is resolved after the arguments have been |
2440 // evaluated. | 2492 // evaluated. |
2441 | 2493 |
2442 // Compute function to call and use the global object as the | 2494 // Compute function to call and use the global object as the |
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4287 __ mov(r2, Operand(0)); | 4339 __ mov(r2, Operand(0)); |
4288 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); | 4340 __ GetBuiltinEntry(r3, Builtins::CALL_NON_FUNCTION); |
4289 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), | 4341 __ Jump(Handle<Code>(Builtins::builtin(Builtins::ArgumentsAdaptorTrampoline)), |
4290 RelocInfo::CODE_TARGET); | 4342 RelocInfo::CODE_TARGET); |
4291 } | 4343 } |
4292 | 4344 |
4293 | 4345 |
4294 #undef __ | 4346 #undef __ |
4295 | 4347 |
4296 } } // namespace v8::internal | 4348 } } // namespace v8::internal |
OLD | NEW |