| 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 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2430 FreeSpaceForFastApiCall(masm()); | 2430 FreeSpaceForFastApiCall(masm()); |
| 2431 | 2431 |
| 2432 __ bind(&miss_before_stack_reserved); | 2432 __ bind(&miss_before_stack_reserved); |
| 2433 GenerateMissBranch(); | 2433 GenerateMissBranch(); |
| 2434 | 2434 |
| 2435 // Return the generated code. | 2435 // Return the generated code. |
| 2436 return GetCode(function); | 2436 return GetCode(function); |
| 2437 } | 2437 } |
| 2438 | 2438 |
| 2439 | 2439 |
| 2440 Handle<Code> CallStubCompiler::CompileCallConstant(Handle<Object> object, | 2440 void CallStubCompiler::CompileHandlerFrontend(Handle<Object> object, |
| 2441 Handle<JSObject> holder, | 2441 Handle<JSObject> holder, |
| 2442 Handle<JSFunction> function, | 2442 Handle<String> name, |
| 2443 Handle<String> name, | 2443 CheckType check, |
| 2444 CheckType check) { | 2444 Label* success) { |
| 2445 // ----------- S t a t e ------------- | 2445 // ----------- S t a t e ------------- |
| 2446 // -- r2 : name | 2446 // -- r2 : name |
| 2447 // -- lr : return address | 2447 // -- lr : return address |
| 2448 // ----------------------------------- | 2448 // ----------------------------------- |
| 2449 if (HasCustomCallGenerator(function)) { | |
| 2450 Handle<Code> code = CompileCustomCall(object, holder, | |
| 2451 Handle<JSGlobalPropertyCell>::null(), | |
| 2452 function, name); | |
| 2453 // A null handle means bail out to the regular compiler code below. | |
| 2454 if (!code.is_null()) return code; | |
| 2455 } | |
| 2456 | |
| 2457 Label miss; | 2449 Label miss; |
| 2458 GenerateNameCheck(name, &miss); | 2450 GenerateNameCheck(name, &miss); |
| 2459 | 2451 |
| 2460 // Get the receiver from the stack | 2452 // Get the receiver from the stack |
| 2461 const int argc = arguments().immediate(); | 2453 const int argc = arguments().immediate(); |
| 2462 __ ldr(r1, MemOperand(sp, argc * kPointerSize)); | 2454 __ ldr(r1, MemOperand(sp, argc * kPointerSize)); |
| 2463 | 2455 |
| 2464 // Check that the receiver isn't a smi. | 2456 // Check that the receiver isn't a smi. |
| 2465 if (check != NUMBER_CHECK) { | 2457 if (check != NUMBER_CHECK) { |
| 2466 __ JumpIfSmi(r1, &miss); | 2458 __ JumpIfSmi(r1, &miss); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2480 | 2472 |
| 2481 // Patch the receiver on the stack with the global proxy if | 2473 // Patch the receiver on the stack with the global proxy if |
| 2482 // necessary. | 2474 // necessary. |
| 2483 if (object->IsGlobalObject()) { | 2475 if (object->IsGlobalObject()) { |
| 2484 __ ldr(r3, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset)); | 2476 __ ldr(r3, FieldMemOperand(r1, GlobalObject::kGlobalReceiverOffset)); |
| 2485 __ str(r3, MemOperand(sp, argc * kPointerSize)); | 2477 __ str(r3, MemOperand(sp, argc * kPointerSize)); |
| 2486 } | 2478 } |
| 2487 break; | 2479 break; |
| 2488 | 2480 |
| 2489 case STRING_CHECK: | 2481 case STRING_CHECK: |
| 2490 if (function->IsBuiltin() || !function->shared()->is_classic_mode()) { | 2482 // Check that the object is a two-byte string or a symbol. |
| 2491 // Check that the object is a two-byte string or a symbol. | 2483 __ CompareObjectType(r1, r3, r3, FIRST_NONSTRING_TYPE); |
| 2492 __ CompareObjectType(r1, r3, r3, FIRST_NONSTRING_TYPE); | 2484 __ b(ge, &miss); |
| 2493 __ b(ge, &miss); | 2485 // Check that the maps starting from the prototype haven't changed. |
| 2494 // Check that the maps starting from the prototype haven't changed. | 2486 GenerateDirectLoadGlobalFunctionPrototype( |
| 2495 GenerateDirectLoadGlobalFunctionPrototype( | 2487 masm(), Context::STRING_FUNCTION_INDEX, r0, &miss); |
| 2496 masm(), Context::STRING_FUNCTION_INDEX, r0, &miss); | 2488 CheckPrototypes( |
| 2497 CheckPrototypes( | 2489 Handle<JSObject>(JSObject::cast(object->GetPrototype())), |
| 2498 Handle<JSObject>(JSObject::cast(object->GetPrototype())), | 2490 r0, holder, r3, r1, r4, name, &miss); |
| 2499 r0, holder, r3, r1, r4, name, &miss); | |
| 2500 } else { | |
| 2501 // Calling non-strict non-builtins with a value as the receiver | |
| 2502 // requires boxing. | |
| 2503 __ jmp(&miss); | |
| 2504 } | |
| 2505 break; | 2491 break; |
| 2506 | 2492 |
| 2507 case NUMBER_CHECK: | 2493 case NUMBER_CHECK: { |
| 2508 if (function->IsBuiltin() || !function->shared()->is_classic_mode()) { | 2494 Label fast; |
| 2509 Label fast; | 2495 // Check that the object is a smi or a heap number. |
| 2510 // Check that the object is a smi or a heap number. | 2496 __ JumpIfSmi(r1, &fast); |
| 2511 __ JumpIfSmi(r1, &fast); | 2497 __ CompareObjectType(r1, r0, r0, HEAP_NUMBER_TYPE); |
| 2512 __ CompareObjectType(r1, r0, r0, HEAP_NUMBER_TYPE); | 2498 __ b(ne, &miss); |
| 2513 __ b(ne, &miss); | 2499 __ bind(&fast); |
| 2514 __ bind(&fast); | 2500 // Check that the maps starting from the prototype haven't changed. |
| 2515 // Check that the maps starting from the prototype haven't changed. | 2501 GenerateDirectLoadGlobalFunctionPrototype( |
| 2516 GenerateDirectLoadGlobalFunctionPrototype( | 2502 masm(), Context::NUMBER_FUNCTION_INDEX, r0, &miss); |
| 2517 masm(), Context::NUMBER_FUNCTION_INDEX, r0, &miss); | 2503 CheckPrototypes( |
| 2518 CheckPrototypes( | 2504 Handle<JSObject>(JSObject::cast(object->GetPrototype())), |
| 2519 Handle<JSObject>(JSObject::cast(object->GetPrototype())), | 2505 r0, holder, r3, r1, r4, name, &miss); |
| 2520 r0, holder, r3, r1, r4, name, &miss); | |
| 2521 } else { | |
| 2522 // Calling non-strict non-builtins with a value as the receiver | |
| 2523 // requires boxing. | |
| 2524 __ jmp(&miss); | |
| 2525 } | |
| 2526 break; | 2506 break; |
| 2527 | 2507 } |
| 2528 case BOOLEAN_CHECK: | 2508 case BOOLEAN_CHECK: { |
| 2529 if (function->IsBuiltin() || !function->shared()->is_classic_mode()) { | 2509 Label fast; |
| 2530 Label fast; | 2510 // Check that the object is a boolean. |
| 2531 // Check that the object is a boolean. | 2511 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
| 2532 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 2512 __ cmp(r1, ip); |
| 2533 __ cmp(r1, ip); | 2513 __ b(eq, &fast); |
| 2534 __ b(eq, &fast); | 2514 __ LoadRoot(ip, Heap::kFalseValueRootIndex); |
| 2535 __ LoadRoot(ip, Heap::kFalseValueRootIndex); | 2515 __ cmp(r1, ip); |
| 2536 __ cmp(r1, ip); | 2516 __ b(ne, &miss); |
| 2537 __ b(ne, &miss); | 2517 __ bind(&fast); |
| 2538 __ bind(&fast); | 2518 // Check that the maps starting from the prototype haven't changed. |
| 2539 // Check that the maps starting from the prototype haven't changed. | 2519 GenerateDirectLoadGlobalFunctionPrototype( |
| 2540 GenerateDirectLoadGlobalFunctionPrototype( | 2520 masm(), Context::BOOLEAN_FUNCTION_INDEX, r0, &miss); |
| 2541 masm(), Context::BOOLEAN_FUNCTION_INDEX, r0, &miss); | 2521 CheckPrototypes( |
| 2542 CheckPrototypes( | 2522 Handle<JSObject>(JSObject::cast(object->GetPrototype())), |
| 2543 Handle<JSObject>(JSObject::cast(object->GetPrototype())), | 2523 r0, holder, r3, r1, r4, name, &miss); |
| 2544 r0, holder, r3, r1, r4, name, &miss); | |
| 2545 } else { | |
| 2546 // Calling non-strict non-builtins with a value as the receiver | |
| 2547 // requires boxing. | |
| 2548 __ jmp(&miss); | |
| 2549 } | |
| 2550 break; | 2524 break; |
| 2525 } |
| 2551 } | 2526 } |
| 2552 | 2527 |
| 2528 __ b(success); |
| 2529 |
| 2530 // Handle call cache miss. |
| 2531 __ bind(&miss); |
| 2532 GenerateMissBranch(); |
| 2533 } |
| 2534 |
| 2535 |
| 2536 void CallStubCompiler::CompileHandlerBackend(Handle<JSFunction> function) { |
| 2553 CallKind call_kind = CallICBase::Contextual::decode(extra_state_) | 2537 CallKind call_kind = CallICBase::Contextual::decode(extra_state_) |
| 2554 ? CALL_AS_FUNCTION | 2538 ? CALL_AS_FUNCTION |
| 2555 : CALL_AS_METHOD; | 2539 : CALL_AS_METHOD; |
| 2556 __ InvokeFunction( | 2540 __ InvokeFunction( |
| 2557 function, arguments(), JUMP_FUNCTION, NullCallWrapper(), call_kind); | 2541 function, arguments(), JUMP_FUNCTION, NullCallWrapper(), call_kind); |
| 2542 } |
| 2558 | 2543 |
| 2559 // Handle call cache miss. | 2544 |
| 2560 __ bind(&miss); | 2545 Handle<Code> CallStubCompiler::CompileCallConstant( |
| 2561 GenerateMissBranch(); | 2546 Handle<Object> object, |
| 2547 Handle<JSObject> holder, |
| 2548 Handle<String> name, |
| 2549 CheckType check, |
| 2550 Handle<JSFunction> function) { |
| 2551 if (HasCustomCallGenerator(function)) { |
| 2552 Handle<Code> code = CompileCustomCall(object, holder, |
| 2553 Handle<JSGlobalPropertyCell>::null(), |
| 2554 function, name); |
| 2555 // A null handle means bail out to the regular compiler code below. |
| 2556 if (!code.is_null()) return code; |
| 2557 } |
| 2558 |
| 2559 Label success; |
| 2560 |
| 2561 CompileHandlerFrontend(object, holder, name, check, &success); |
| 2562 __ bind(&success); |
| 2563 CompileHandlerBackend(function); |
| 2564 |
| 2562 | 2565 |
| 2563 // Return the generated code. | 2566 // Return the generated code. |
| 2564 return GetCode(function); | 2567 return GetCode(function); |
| 2565 } | 2568 } |
| 2566 | 2569 |
| 2567 | 2570 |
| 2568 Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object, | 2571 Handle<Code> CallStubCompiler::CompileCallInterceptor(Handle<JSObject> object, |
| 2569 Handle<JSObject> holder, | 2572 Handle<JSObject> holder, |
| 2570 Handle<String> name) { | 2573 Handle<String> name) { |
| 2571 // ----------- S t a t e ------------- | 2574 // ----------- S t a t e ------------- |
| (...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4165 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4168 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
| 4166 } | 4169 } |
| 4167 } | 4170 } |
| 4168 | 4171 |
| 4169 | 4172 |
| 4170 #undef __ | 4173 #undef __ |
| 4171 | 4174 |
| 4172 } } // namespace v8::internal | 4175 } } // namespace v8::internal |
| 4173 | 4176 |
| 4174 #endif // V8_TARGET_ARCH_ARM | 4177 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |