Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 2050853003: [stubs] StringToNumberStub --> StringToNumber builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x87/builtins-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after
2409 2409
2410 void NonNumberToNumberStub::Generate(MacroAssembler* masm) { 2410 void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
2411 // The NonNumberToNumber stub takes one argument in rax. 2411 // The NonNumberToNumber stub takes one argument in rax.
2412 __ AssertNotNumber(rax); 2412 __ AssertNotNumber(rax);
2413 2413
2414 Label not_string; 2414 Label not_string;
2415 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); 2415 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi);
2416 // rax: object 2416 // rax: object
2417 // rdi: object map 2417 // rdi: object map
2418 __ j(above_equal, &not_string, Label::kNear); 2418 __ j(above_equal, &not_string, Label::kNear);
2419 StringToNumberStub stub(masm->isolate()); 2419 __ Jump(isolate()->builtins()->StringToNumber(), RelocInfo::CODE_TARGET);
2420 __ TailCallStub(&stub);
2421 __ bind(&not_string); 2420 __ bind(&not_string);
2422 2421
2423 Label not_oddball; 2422 Label not_oddball;
2424 __ CmpInstanceType(rdi, ODDBALL_TYPE); 2423 __ CmpInstanceType(rdi, ODDBALL_TYPE);
2425 __ j(not_equal, &not_oddball, Label::kNear); 2424 __ j(not_equal, &not_oddball, Label::kNear);
2426 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset)); 2425 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset));
2427 __ Ret(); 2426 __ Ret();
2428 __ bind(&not_oddball); 2427 __ bind(&not_oddball);
2429 2428
2430 __ PopReturnAddressTo(rcx); // Pop return address. 2429 __ PopReturnAddressTo(rcx); // Pop return address.
2431 __ Push(rax); // Push argument. 2430 __ Push(rax); // Push argument.
2432 __ PushReturnAddressFrom(rcx); // Push return address. 2431 __ PushReturnAddressFrom(rcx); // Push return address.
2433 __ TailCallRuntime(Runtime::kToNumber); 2432 __ TailCallRuntime(Runtime::kToNumber);
2434 } 2433 }
2435 2434
2436 void StringToNumberStub::Generate(MacroAssembler* masm) {
2437 // The StringToNumber stub takes one argument in rax.
2438 __ AssertString(rax);
2439
2440 // Check if string has a cached array index.
2441 Label runtime;
2442 __ testl(FieldOperand(rax, String::kHashFieldOffset),
2443 Immediate(String::kContainsCachedArrayIndexMask));
2444 __ j(not_zero, &runtime, Label::kNear);
2445 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset));
2446 __ IndexFromHash(rax, rax);
2447 __ Ret();
2448
2449 __ bind(&runtime);
2450 __ PopReturnAddressTo(rcx); // Pop return address.
2451 __ Push(rax); // Push argument.
2452 __ PushReturnAddressFrom(rcx); // Push return address.
2453 __ TailCallRuntime(Runtime::kStringToNumber);
2454 }
2455
2456 void ToStringStub::Generate(MacroAssembler* masm) { 2435 void ToStringStub::Generate(MacroAssembler* masm) {
2457 // The ToString stub takes one argument in rax. 2436 // The ToString stub takes one argument in rax.
2458 Label is_number; 2437 Label is_number;
2459 __ JumpIfSmi(rax, &is_number, Label::kNear); 2438 __ JumpIfSmi(rax, &is_number, Label::kNear);
2460 2439
2461 Label not_string; 2440 Label not_string;
2462 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); 2441 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi);
2463 // rax: receiver 2442 // rax: receiver
2464 // rdi: receiver map 2443 // rdi: receiver map
2465 __ j(above_equal, &not_string, Label::kNear); 2444 __ j(above_equal, &not_string, Label::kNear);
(...skipping 2980 matching lines...) Expand 10 before | Expand all | Expand 10 after
5446 kStackUnwindSpace, nullptr, return_value_operand, 5425 kStackUnwindSpace, nullptr, return_value_operand,
5447 NULL); 5426 NULL);
5448 } 5427 }
5449 5428
5450 #undef __ 5429 #undef __
5451 5430
5452 } // namespace internal 5431 } // namespace internal
5453 } // namespace v8 5432 } // namespace v8
5454 5433
5455 #endif // V8_TARGET_ARCH_X64 5434 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x87/builtins-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698