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

Side by Side Diff: src/x87/code-stubs-x87.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/x87/builtins-x87.cc ('k') | no next file » | 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_X87 5 #if V8_TARGET_ARCH_X87
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 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 2191
2192 void NonNumberToNumberStub::Generate(MacroAssembler* masm) { 2192 void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
2193 // The NonNumberToNumber stub takes one argument in eax. 2193 // The NonNumberToNumber stub takes one argument in eax.
2194 __ AssertNotNumber(eax); 2194 __ AssertNotNumber(eax);
2195 2195
2196 Label not_string; 2196 Label not_string;
2197 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); 2197 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi);
2198 // eax: object 2198 // eax: object
2199 // edi: object map 2199 // edi: object map
2200 __ j(above_equal, &not_string, Label::kNear); 2200 __ j(above_equal, &not_string, Label::kNear);
2201 StringToNumberStub stub(masm->isolate()); 2201 __ Jump(isolate()->builtins()->StringToNumber(), RelocInfo::CODE_TARGET);
2202 __ TailCallStub(&stub);
2203 __ bind(&not_string); 2202 __ bind(&not_string);
2204 2203
2205 Label not_oddball; 2204 Label not_oddball;
2206 __ CmpInstanceType(edi, ODDBALL_TYPE); 2205 __ CmpInstanceType(edi, ODDBALL_TYPE);
2207 __ j(not_equal, &not_oddball, Label::kNear); 2206 __ j(not_equal, &not_oddball, Label::kNear);
2208 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); 2207 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset));
2209 __ Ret(); 2208 __ Ret();
2210 __ bind(&not_oddball); 2209 __ bind(&not_oddball);
2211 2210
2212 __ pop(ecx); // Pop return address. 2211 __ pop(ecx); // Pop return address.
2213 __ push(eax); // Push argument. 2212 __ push(eax); // Push argument.
2214 __ push(ecx); // Push return address. 2213 __ push(ecx); // Push return address.
2215 __ TailCallRuntime(Runtime::kToNumber); 2214 __ TailCallRuntime(Runtime::kToNumber);
2216 } 2215 }
2217 2216
2218 void StringToNumberStub::Generate(MacroAssembler* masm) {
2219 // The StringToNumber stub takes one argument in eax.
2220 __ AssertString(eax);
2221
2222 // Check if string has a cached array index.
2223 Label runtime;
2224 __ test(FieldOperand(eax, String::kHashFieldOffset),
2225 Immediate(String::kContainsCachedArrayIndexMask));
2226 __ j(not_zero, &runtime, Label::kNear);
2227 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset));
2228 __ IndexFromHash(eax, eax);
2229 __ Ret();
2230
2231 __ bind(&runtime);
2232 __ PopReturnAddressTo(ecx); // Pop return address.
2233 __ Push(eax); // Push argument.
2234 __ PushReturnAddressFrom(ecx); // Push return address.
2235 __ TailCallRuntime(Runtime::kStringToNumber);
2236 }
2237
2238 void ToStringStub::Generate(MacroAssembler* masm) { 2217 void ToStringStub::Generate(MacroAssembler* masm) {
2239 // The ToString stub takes one argument in eax. 2218 // The ToString stub takes one argument in eax.
2240 Label is_number; 2219 Label is_number;
2241 __ JumpIfSmi(eax, &is_number, Label::kNear); 2220 __ JumpIfSmi(eax, &is_number, Label::kNear);
2242 2221
2243 Label not_string; 2222 Label not_string;
2244 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); 2223 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi);
2245 // eax: receiver 2224 // eax: receiver
2246 // edi: receiver map 2225 // edi: receiver map
2247 __ j(above_equal, &not_string, Label::kNear); 2226 __ j(above_equal, &not_string, Label::kNear);
(...skipping 3143 matching lines...) Expand 10 before | Expand all | Expand 10 after
5391 kStackUnwindSpace, nullptr, return_value_operand, 5370 kStackUnwindSpace, nullptr, return_value_operand,
5392 NULL); 5371 NULL);
5393 } 5372 }
5394 5373
5395 #undef __ 5374 #undef __
5396 5375
5397 } // namespace internal 5376 } // namespace internal
5398 } // namespace v8 5377 } // namespace v8
5399 5378
5400 #endif // V8_TARGET_ARCH_X87 5379 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x87/builtins-x87.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698