| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2423 FreeSpaceForFastApiCall(masm()); | 2423 FreeSpaceForFastApiCall(masm()); |
| 2424 | 2424 |
| 2425 __ bind(&miss_before_stack_reserved); | 2425 __ bind(&miss_before_stack_reserved); |
| 2426 GenerateMissBranch(); | 2426 GenerateMissBranch(); |
| 2427 | 2427 |
| 2428 // Return the generated code. | 2428 // Return the generated code. |
| 2429 return GetCode(function); | 2429 return GetCode(function); |
| 2430 } | 2430 } |
| 2431 | 2431 |
| 2432 | 2432 |
| 2433 Handle<Code> CallStubCompiler::CompileCallConstant(Handle<Object> object, | 2433 void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object, |
| 2434 Handle<JSObject> holder, | 2434 Handle<JSObject> holder, |
| 2435 Handle<JSFunction> function, | 2435 Handle<String> name, |
| 2436 Handle<String> name, | 2436 CheckType check, |
| 2437 CheckType check) { | 2437 Label* success) { |
| 2438 // ----------- S t a t e ------------- | 2438 // ----------- S t a t e ------------- |
| 2439 // -- a2 : name | 2439 // -- a2 : name |
| 2440 // -- ra : return address | 2440 // -- ra : return address |
| 2441 // ----------------------------------- | 2441 // ----------------------------------- |
| 2442 if (HasCustomCallGenerator(function)) { | |
| 2443 Handle<Code> code = CompileCustomCall(object, holder, | |
| 2444 Handle<JSGlobalPropertyCell>::null(), | |
| 2445 function, name); | |
| 2446 // A null handle means bail out to the regular compiler code below. | |
| 2447 if (!code.is_null()) return code; | |
| 2448 } | |
| 2449 | |
| 2450 Label miss; | 2442 Label miss; |
| 2451 | |
| 2452 GenerateNameCheck(name, &miss); | 2443 GenerateNameCheck(name, &miss); |
| 2453 | 2444 |
| 2454 // Get the receiver from the stack. | 2445 // Get the receiver from the stack. |
| 2455 const int argc = arguments().immediate(); | 2446 const int argc = arguments().immediate(); |
| 2456 __ lw(a1, MemOperand(sp, argc * kPointerSize)); | 2447 __ lw(a1, MemOperand(sp, argc * kPointerSize)); |
| 2457 | 2448 |
| 2458 // Check that the receiver isn't a smi. | 2449 // Check that the receiver isn't a smi. |
| 2459 if (check != NUMBER_CHECK) { | 2450 if (check != NUMBER_CHECK) { |
| 2460 __ JumpIfSmi(a1, &miss); | 2451 __ JumpIfSmi(a1, &miss); |
| 2461 } | 2452 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2474 | 2465 |
| 2475 // Patch the receiver on the stack with the global proxy if | 2466 // Patch the receiver on the stack with the global proxy if |
| 2476 // necessary. | 2467 // necessary. |
| 2477 if (object->IsGlobalObject()) { | 2468 if (object->IsGlobalObject()) { |
| 2478 __ lw(a3, FieldMemOperand(a1, GlobalObject::kGlobalReceiverOffset)); | 2469 __ lw(a3, FieldMemOperand(a1, GlobalObject::kGlobalReceiverOffset)); |
| 2479 __ sw(a3, MemOperand(sp, argc * kPointerSize)); | 2470 __ sw(a3, MemOperand(sp, argc * kPointerSize)); |
| 2480 } | 2471 } |
| 2481 break; | 2472 break; |
| 2482 | 2473 |
| 2483 case STRING_CHECK: | 2474 case STRING_CHECK: |
| 2484 if (function->IsBuiltin() || !function->shared()->is_classic_mode()) { | 2475 // Check that the object is a two-byte string or a symbol. |
| 2485 // Check that the object is a two-byte string or a symbol. | 2476 __ GetObjectType(a1, a3, a3); |
| 2486 __ GetObjectType(a1, a3, a3); | 2477 __ Branch(&miss, Ugreater_equal, a3, Operand(FIRST_NONSTRING_TYPE)); |
| 2487 __ Branch(&miss, Ugreater_equal, a3, Operand(FIRST_NONSTRING_TYPE)); | 2478 // Check that the maps starting from the prototype haven't changed. |
| 2488 // Check that the maps starting from the prototype haven't changed. | 2479 GenerateDirectLoadGlobalFunctionPrototype( |
| 2489 GenerateDirectLoadGlobalFunctionPrototype( | 2480 masm(), Context::STRING_FUNCTION_INDEX, a0, &miss); |
| 2490 masm(), Context::STRING_FUNCTION_INDEX, a0, &miss); | 2481 CheckPrototypes( |
| 2491 CheckPrototypes( | 2482 Handle<JSObject>(JSObject::cast(object->GetPrototype())), |
| 2492 Handle<JSObject>(JSObject::cast(object->GetPrototype())), | 2483 a0, holder, a3, a1, t0, name, &miss); |
| 2493 a0, holder, a3, a1, t0, name, &miss); | |
| 2494 } else { | |
| 2495 // Calling non-strict non-builtins with a value as the receiver | |
| 2496 // requires boxing. | |
| 2497 __ jmp(&miss); | |
| 2498 } | |
| 2499 break; | 2484 break; |
| 2500 | 2485 |
| 2501 case NUMBER_CHECK: | 2486 case NUMBER_CHECK: { |
| 2502 if (function->IsBuiltin() || !function->shared()->is_classic_mode()) { | |
| 2503 Label fast; | 2487 Label fast; |
| 2504 // Check that the object is a smi or a heap number. | 2488 // Check that the object is a smi or a heap number. |
| 2505 __ JumpIfSmi(a1, &fast); | 2489 __ JumpIfSmi(a1, &fast); |
| 2506 __ GetObjectType(a1, a0, a0); | 2490 __ GetObjectType(a1, a0, a0); |
| 2507 __ Branch(&miss, ne, a0, Operand(HEAP_NUMBER_TYPE)); | 2491 __ Branch(&miss, ne, a0, Operand(HEAP_NUMBER_TYPE)); |
| 2508 __ bind(&fast); | 2492 __ bind(&fast); |
| 2509 // Check that the maps starting from the prototype haven't changed. | 2493 // Check that the maps starting from the prototype haven't changed. |
| 2510 GenerateDirectLoadGlobalFunctionPrototype( | 2494 GenerateDirectLoadGlobalFunctionPrototype( |
| 2511 masm(), Context::NUMBER_FUNCTION_INDEX, a0, &miss); | 2495 masm(), Context::NUMBER_FUNCTION_INDEX, a0, &miss); |
| 2512 CheckPrototypes( | 2496 CheckPrototypes( |
| 2513 Handle<JSObject>(JSObject::cast(object->GetPrototype())), | 2497 Handle<JSObject>(JSObject::cast(object->GetPrototype())), |
| 2514 a0, holder, a3, a1, t0, name, &miss); | 2498 a0, holder, a3, a1, t0, name, &miss); |
| 2515 } else { | |
| 2516 // Calling non-strict non-builtins with a value as the receiver | |
| 2517 // requires boxing. | |
| 2518 __ jmp(&miss); | |
| 2519 } | |
| 2520 break; | |
| 2521 | |
| 2522 case BOOLEAN_CHECK: | |
| 2523 if (function->IsBuiltin() || !function->shared()->is_classic_mode()) { | |
| 2524 Label fast; | |
| 2525 // Check that the object is a boolean. | |
| 2526 __ LoadRoot(t0, Heap::kTrueValueRootIndex); | |
| 2527 __ Branch(&fast, eq, a1, Operand(t0)); | |
| 2528 __ LoadRoot(t0, Heap::kFalseValueRootIndex); | |
| 2529 __ Branch(&miss, ne, a1, Operand(t0)); | |
| 2530 __ bind(&fast); | |
| 2531 // Check that the maps starting from the prototype haven't changed. | |
| 2532 GenerateDirectLoadGlobalFunctionPrototype( | |
| 2533 masm(), Context::BOOLEAN_FUNCTION_INDEX, a0, &miss); | |
| 2534 CheckPrototypes( | |
| 2535 Handle<JSObject>(JSObject::cast(object->GetPrototype())), | |
| 2536 a0, holder, a3, a1, t0, name, &miss); | |
| 2537 } else { | |
| 2538 // Calling non-strict non-builtins with a value as the receiver | |
| 2539 // requires boxing. | |
| 2540 __ jmp(&miss); | |
| 2541 } | |
| 2542 break; | 2499 break; |
| 2543 } | 2500 } |
| 2501 case BOOLEAN_CHECK: { |
| 2502 Label fast; |
| 2503 // Check that the object is a boolean. |
| 2504 __ LoadRoot(t0, Heap::kTrueValueRootIndex); |
| 2505 __ Branch(&fast, eq, a1, Operand(t0)); |
| 2506 __ LoadRoot(t0, Heap::kFalseValueRootIndex); |
| 2507 __ Branch(&miss, ne, a1, Operand(t0)); |
| 2508 __ bind(&fast); |
| 2509 // Check that the maps starting from the prototype haven't changed. |
| 2510 GenerateDirectLoadGlobalFunctionPrototype( |
| 2511 masm(), Context::BOOLEAN_FUNCTION_INDEX, a0, &miss); |
| 2512 CheckPrototypes( |
| 2513 Handle<JSObject>(JSObject::cast(object->GetPrototype())), |
| 2514 a0, holder, a3, a1, t0, name, &miss); |
| 2515 break; |
| 2516 } |
| 2517 } |
| 2544 | 2518 |
| 2519 __ jmp(success); |
| 2520 |
| 2521 // Handle call cache miss. |
| 2522 __ bind(&miss); |
| 2523 |
| 2524 GenerateMissBranch(); |
| 2525 } |
| 2526 |
| 2527 |
| 2528 void CallStubCompiler::CompileHandlerBackend(Handle<JSFunction> function) { |
| 2545 CallKind call_kind = CallICBase::Contextual::decode(extra_state_) | 2529 CallKind call_kind = CallICBase::Contextual::decode(extra_state_) |
| 2546 ? CALL_AS_FUNCTION | 2530 ? CALL_AS_FUNCTION |
| 2547 : CALL_AS_METHOD; | 2531 : CALL_AS_METHOD; |
| 2548 __ InvokeFunction( | 2532 __ InvokeFunction( |
| 2549 function, arguments(), JUMP_FUNCTION, NullCallWrapper(), call_kind); | 2533 function, arguments(), JUMP_FUNCTION, NullCallWrapper(), call_kind); |
| 2534 } |
| 2550 | 2535 |
| 2551 // Handle call cache miss. | |
| 2552 __ bind(&miss); | |
| 2553 | 2536 |
| 2554 GenerateMissBranch(); | 2537 Handle<Code> CallStubCompiler::CompileCallConstant( |
| 2538 Handle<Object> object, |
| 2539 Handle<JSObject> holder, |
| 2540 Handle<String> name, |
| 2541 CheckType check, |
| 2542 Handle<JSFunction> function) { |
| 2543 if (HasCustomCallGenerator(function)) { |
| 2544 Handle<Code> code = CompileCustomCall(object, holder, |
| 2545 Handle<JSGlobalPropertyCell>::null(), |
| 2546 function, name); |
| 2547 // A null handle means bail out to the regular compiler code below. |
| 2548 if (!code.is_null()) return code; |
| 2549 } |
| 2550 |
| 2551 Label success; |
| 2552 |
| 2553 CompileHandlerFrontend(object, holder, name, check, &success); |
| 2554 __ bind(&success); |
| 2555 CompileHandlerBackend(function); |
| 2555 | 2556 |
| 2556 // Return the generated code. | 2557 // Return the generated code. |
| 2557 return GetCode(function); | 2558 return GetCode(function); |
| 2558 } | 2559 } |
| 2559 | 2560 |
| 2560 | 2561 |
| 2561 Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object, | 2562 Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object, |
| 2562 Handle<JSObject> holder, | 2563 Handle<JSObject> holder, |
| 2563 Handle<String> name) { | 2564 Handle<String> name) { |
| 2564 // ----------- S t a t e ------------- | 2565 // ----------- S t a t e ------------- |
| (...skipping 1653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4218 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4219 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
| 4219 } | 4220 } |
| 4220 } | 4221 } |
| 4221 | 4222 |
| 4222 | 4223 |
| 4223 #undef __ | 4224 #undef __ |
| 4224 | 4225 |
| 4225 } } // namespace v8::internal | 4226 } } // namespace v8::internal |
| 4226 | 4227 |
| 4227 #endif // V8_TARGET_ARCH_MIPS | 4228 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |