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

Side by Side Diff: src/ia32/code-stubs-ia32.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/ia32/builtins-ia32.cc ('k') | src/mips/builtins-mips.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_IA32 5 #if V8_TARGET_ARCH_IA32
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/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after
2469 2469
2470 void NonNumberToNumberStub::Generate(MacroAssembler* masm) { 2470 void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
2471 // The NonNumberToNumber stub takes one argument in eax. 2471 // The NonNumberToNumber stub takes one argument in eax.
2472 __ AssertNotNumber(eax); 2472 __ AssertNotNumber(eax);
2473 2473
2474 Label not_string; 2474 Label not_string;
2475 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); 2475 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi);
2476 // eax: object 2476 // eax: object
2477 // edi: object map 2477 // edi: object map
2478 __ j(above_equal, &not_string, Label::kNear); 2478 __ j(above_equal, &not_string, Label::kNear);
2479 StringToNumberStub stub(masm->isolate()); 2479 __ Jump(isolate()->builtins()->StringToNumber(), RelocInfo::CODE_TARGET);
2480 __ TailCallStub(&stub);
2481 __ bind(&not_string); 2480 __ bind(&not_string);
2482 2481
2483 Label not_oddball; 2482 Label not_oddball;
2484 __ CmpInstanceType(edi, ODDBALL_TYPE); 2483 __ CmpInstanceType(edi, ODDBALL_TYPE);
2485 __ j(not_equal, &not_oddball, Label::kNear); 2484 __ j(not_equal, &not_oddball, Label::kNear);
2486 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); 2485 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset));
2487 __ Ret(); 2486 __ Ret();
2488 __ bind(&not_oddball); 2487 __ bind(&not_oddball);
2489 2488
2490 __ pop(ecx); // Pop return address. 2489 __ pop(ecx); // Pop return address.
2491 __ push(eax); // Push argument. 2490 __ push(eax); // Push argument.
2492 __ push(ecx); // Push return address. 2491 __ push(ecx); // Push return address.
2493 __ TailCallRuntime(Runtime::kToNumber); 2492 __ TailCallRuntime(Runtime::kToNumber);
2494 } 2493 }
2495 2494
2496 void StringToNumberStub::Generate(MacroAssembler* masm) {
2497 // The StringToNumber stub takes one argument in eax.
2498 __ AssertString(eax);
2499
2500 // Check if string has a cached array index.
2501 Label runtime;
2502 __ test(FieldOperand(eax, String::kHashFieldOffset),
2503 Immediate(String::kContainsCachedArrayIndexMask));
2504 __ j(not_zero, &runtime, Label::kNear);
2505 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset));
2506 __ IndexFromHash(eax, eax);
2507 __ Ret();
2508
2509 __ bind(&runtime);
2510 __ PopReturnAddressTo(ecx); // Pop return address.
2511 __ Push(eax); // Push argument.
2512 __ PushReturnAddressFrom(ecx); // Push return address.
2513 __ TailCallRuntime(Runtime::kStringToNumber);
2514 }
2515
2516 void ToStringStub::Generate(MacroAssembler* masm) { 2495 void ToStringStub::Generate(MacroAssembler* masm) {
2517 // The ToString stub takes one argument in eax. 2496 // The ToString stub takes one argument in eax.
2518 Label is_number; 2497 Label is_number;
2519 __ JumpIfSmi(eax, &is_number, Label::kNear); 2498 __ JumpIfSmi(eax, &is_number, Label::kNear);
2520 2499
2521 Label not_string; 2500 Label not_string;
2522 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); 2501 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi);
2523 // eax: receiver 2502 // eax: receiver
2524 // edi: receiver map 2503 // edi: receiver map
2525 __ j(above_equal, &not_string, Label::kNear); 2504 __ j(above_equal, &not_string, Label::kNear);
(...skipping 3197 matching lines...) Expand 10 before | Expand all | Expand 10 after
5723 kStackUnwindSpace, nullptr, return_value_operand, 5702 kStackUnwindSpace, nullptr, return_value_operand,
5724 NULL); 5703 NULL);
5725 } 5704 }
5726 5705
5727 #undef __ 5706 #undef __
5728 5707
5729 } // namespace internal 5708 } // namespace internal
5730 } // namespace v8 5709 } // namespace v8
5731 5710
5732 #endif // V8_TARGET_ARCH_IA32 5711 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/builtins-ia32.cc ('k') | src/mips/builtins-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698