OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 2370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2381 // rbx: instance type | 2381 // rbx: instance type |
2382 // rcx: sub string length (smi) | 2382 // rcx: sub string length (smi) |
2383 // rdx: from index (smi) | 2383 // rdx: from index (smi) |
2384 StringCharAtGenerator generator(rax, rdx, rcx, rax, &runtime, &runtime, | 2384 StringCharAtGenerator generator(rax, rdx, rcx, rax, &runtime, &runtime, |
2385 &runtime, RECEIVER_IS_STRING); | 2385 &runtime, RECEIVER_IS_STRING); |
2386 generator.GenerateFast(masm); | 2386 generator.GenerateFast(masm); |
2387 __ ret(SUB_STRING_ARGUMENT_COUNT * kPointerSize); | 2387 __ ret(SUB_STRING_ARGUMENT_COUNT * kPointerSize); |
2388 generator.SkipSlow(masm, &runtime); | 2388 generator.SkipSlow(masm, &runtime); |
2389 } | 2389 } |
2390 | 2390 |
2391 | |
2392 void ToNumberStub::Generate(MacroAssembler* masm) { | |
2393 // The ToNumber stub takes one argument in rax. | |
2394 Label not_smi; | |
2395 __ JumpIfNotSmi(rax, ¬_smi, Label::kNear); | |
2396 __ Ret(); | |
2397 __ bind(¬_smi); | |
2398 | |
2399 Label not_heap_number; | |
2400 __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset), | |
2401 Heap::kHeapNumberMapRootIndex); | |
2402 __ j(not_equal, ¬_heap_number, Label::kNear); | |
2403 __ Ret(); | |
2404 __ bind(¬_heap_number); | |
2405 | |
2406 NonNumberToNumberStub stub(masm->isolate()); | |
2407 __ TailCallStub(&stub); | |
2408 } | |
2409 | |
2410 void NonNumberToNumberStub::Generate(MacroAssembler* masm) { | |
2411 // The NonNumberToNumber stub takes one argument in rax. | |
2412 __ AssertNotNumber(rax); | |
2413 | |
2414 Label not_string; | |
2415 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); | |
2416 // rax: object | |
2417 // rdi: object map | |
2418 __ j(above_equal, ¬_string, Label::kNear); | |
2419 __ Jump(isolate()->builtins()->StringToNumber(), RelocInfo::CODE_TARGET); | |
2420 __ bind(¬_string); | |
2421 | |
2422 Label not_oddball; | |
2423 __ CmpInstanceType(rdi, ODDBALL_TYPE); | |
2424 __ j(not_equal, ¬_oddball, Label::kNear); | |
2425 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset)); | |
2426 __ Ret(); | |
2427 __ bind(¬_oddball); | |
2428 | |
2429 __ PopReturnAddressTo(rcx); // Pop return address. | |
2430 __ Push(rax); // Push argument. | |
2431 __ PushReturnAddressFrom(rcx); // Push return address. | |
2432 __ TailCallRuntime(Runtime::kToNumber); | |
2433 } | |
2434 | |
2435 void ToStringStub::Generate(MacroAssembler* masm) { | 2391 void ToStringStub::Generate(MacroAssembler* masm) { |
2436 // The ToString stub takes one argument in rax. | 2392 // The ToString stub takes one argument in rax. |
2437 Label is_number; | 2393 Label is_number; |
2438 __ JumpIfSmi(rax, &is_number, Label::kNear); | 2394 __ JumpIfSmi(rax, &is_number, Label::kNear); |
2439 | 2395 |
2440 Label not_string; | 2396 Label not_string; |
2441 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); | 2397 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); |
2442 // rax: receiver | 2398 // rax: receiver |
2443 // rdi: receiver map | 2399 // rdi: receiver map |
2444 __ j(above_equal, ¬_string, Label::kNear); | 2400 __ j(above_equal, ¬_string, Label::kNear); |
(...skipping 14 matching lines...) Expand all Loading... |
2459 __ movp(rax, FieldOperand(rax, Oddball::kToStringOffset)); | 2415 __ movp(rax, FieldOperand(rax, Oddball::kToStringOffset)); |
2460 __ Ret(); | 2416 __ Ret(); |
2461 __ bind(¬_oddball); | 2417 __ bind(¬_oddball); |
2462 | 2418 |
2463 __ PopReturnAddressTo(rcx); // Pop return address. | 2419 __ PopReturnAddressTo(rcx); // Pop return address. |
2464 __ Push(rax); // Push argument. | 2420 __ Push(rax); // Push argument. |
2465 __ PushReturnAddressFrom(rcx); // Push return address. | 2421 __ PushReturnAddressFrom(rcx); // Push return address. |
2466 __ TailCallRuntime(Runtime::kToString); | 2422 __ TailCallRuntime(Runtime::kToString); |
2467 } | 2423 } |
2468 | 2424 |
2469 | |
2470 void ToNameStub::Generate(MacroAssembler* masm) { | 2425 void ToNameStub::Generate(MacroAssembler* masm) { |
2471 // The ToName stub takes one argument in rax. | 2426 // The ToName stub takes one argument in rax. |
2472 Label is_number; | 2427 Label is_number; |
2473 __ JumpIfSmi(rax, &is_number, Label::kNear); | 2428 __ JumpIfSmi(rax, &is_number, Label::kNear); |
2474 | 2429 |
2475 Label not_name; | 2430 Label not_name; |
2476 STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE); | 2431 STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE); |
2477 __ CmpObjectType(rax, LAST_NAME_TYPE, rdi); | 2432 __ CmpObjectType(rax, LAST_NAME_TYPE, rdi); |
2478 // rax: receiver | 2433 // rax: receiver |
2479 // rdi: receiver map | 2434 // rdi: receiver map |
(...skipping 2945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5425 kStackUnwindSpace, nullptr, return_value_operand, | 5380 kStackUnwindSpace, nullptr, return_value_operand, |
5426 NULL); | 5381 NULL); |
5427 } | 5382 } |
5428 | 5383 |
5429 #undef __ | 5384 #undef __ |
5430 | 5385 |
5431 } // namespace internal | 5386 } // namespace internal |
5432 } // namespace v8 | 5387 } // namespace v8 |
5433 | 5388 |
5434 #endif // V8_TARGET_ARCH_X64 | 5389 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |