| OLD | NEW |
| 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 2310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2321 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); | 2321 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); |
| 2322 __ Ret(); | 2322 __ Ret(); |
| 2323 __ bind(¬_smi); | 2323 __ bind(¬_smi); |
| 2324 | 2324 |
| 2325 Label not_heap_number; | 2325 Label not_heap_number; |
| 2326 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); | 2326 __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); |
| 2327 __ j(not_equal, ¬_heap_number, Label::kNear); | 2327 __ j(not_equal, ¬_heap_number, Label::kNear); |
| 2328 __ Ret(); | 2328 __ Ret(); |
| 2329 __ bind(¬_heap_number); | 2329 __ bind(¬_heap_number); |
| 2330 | 2330 |
| 2331 Label not_string, slow_string; | 2331 NonNumberToNumberStub stub(masm->isolate()); |
| 2332 __ TailCallStub(&stub); |
| 2333 } |
| 2334 |
| 2335 void NonNumberToNumberStub::Generate(MacroAssembler* masm) { |
| 2336 // The NonNumberToNumber stub takes one argument in eax. |
| 2337 __ AssertNotNumber(eax); |
| 2338 |
| 2339 Label not_string; |
| 2332 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); | 2340 __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); |
| 2333 // eax: object | 2341 // eax: object |
| 2334 // edi: object map | 2342 // edi: object map |
| 2335 __ j(above_equal, ¬_string, Label::kNear); | 2343 __ j(above_equal, ¬_string, Label::kNear); |
| 2336 // Check if string has a cached array index. | 2344 StringToNumberStub stub(masm->isolate()); |
| 2337 __ test(FieldOperand(eax, String::kHashFieldOffset), | 2345 __ TailCallStub(&stub); |
| 2338 Immediate(String::kContainsCachedArrayIndexMask)); | |
| 2339 __ j(not_zero, &slow_string, Label::kNear); | |
| 2340 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); | |
| 2341 __ IndexFromHash(eax, eax); | |
| 2342 __ Ret(); | |
| 2343 __ bind(&slow_string); | |
| 2344 __ pop(ecx); // Pop return address. | |
| 2345 __ push(eax); // Push argument. | |
| 2346 __ push(ecx); // Push return address. | |
| 2347 __ TailCallRuntime(Runtime::kStringToNumber); | |
| 2348 __ bind(¬_string); | 2346 __ bind(¬_string); |
| 2349 | 2347 |
| 2350 Label not_oddball; | 2348 Label not_oddball; |
| 2351 __ CmpInstanceType(edi, ODDBALL_TYPE); | 2349 __ CmpInstanceType(edi, ODDBALL_TYPE); |
| 2352 __ j(not_equal, ¬_oddball, Label::kNear); | 2350 __ j(not_equal, ¬_oddball, Label::kNear); |
| 2353 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); | 2351 __ mov(eax, FieldOperand(eax, Oddball::kToNumberOffset)); |
| 2354 __ Ret(); | 2352 __ Ret(); |
| 2355 __ bind(¬_oddball); | 2353 __ bind(¬_oddball); |
| 2356 | 2354 |
| 2357 __ pop(ecx); // Pop return address. | 2355 __ pop(ecx); // Pop return address. |
| 2358 __ push(eax); // Push argument. | 2356 __ push(eax); // Push argument. |
| 2359 __ push(ecx); // Push return address. | 2357 __ push(ecx); // Push return address. |
| 2360 __ TailCallRuntime(Runtime::kToNumber); | 2358 __ TailCallRuntime(Runtime::kToNumber); |
| 2361 } | 2359 } |
| 2362 | 2360 |
| 2361 void StringToNumberStub::Generate(MacroAssembler* masm) { |
| 2362 // The StringToNumber stub takes one argument in eax. |
| 2363 __ AssertString(eax); |
| 2364 |
| 2365 // Check if string has a cached array index. |
| 2366 Label runtime; |
| 2367 __ test(FieldOperand(eax, String::kHashFieldOffset), |
| 2368 Immediate(String::kContainsCachedArrayIndexMask)); |
| 2369 __ j(not_zero, &runtime, Label::kNear); |
| 2370 __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); |
| 2371 __ IndexFromHash(eax, eax); |
| 2372 __ Ret(); |
| 2373 |
| 2374 __ bind(&runtime); |
| 2375 __ PopReturnAddressTo(ecx); // Pop return address. |
| 2376 __ Push(eax); // Push argument. |
| 2377 __ PushReturnAddressFrom(ecx); // Push return address. |
| 2378 __ TailCallRuntime(Runtime::kStringToNumber); |
| 2379 } |
| 2363 | 2380 |
| 2364 void ToLengthStub::Generate(MacroAssembler* masm) { | 2381 void ToLengthStub::Generate(MacroAssembler* masm) { |
| 2365 // The ToLength stub takes on argument in eax. | 2382 // The ToLength stub takes on argument in eax. |
| 2366 Label not_smi, positive_smi; | 2383 Label not_smi, positive_smi; |
| 2367 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); | 2384 __ JumpIfNotSmi(eax, ¬_smi, Label::kNear); |
| 2368 STATIC_ASSERT(kSmiTag == 0); | 2385 STATIC_ASSERT(kSmiTag == 0); |
| 2369 __ test(eax, eax); | 2386 __ test(eax, eax); |
| 2370 __ j(greater_equal, &positive_smi, Label::kNear); | 2387 __ j(greater_equal, &positive_smi, Label::kNear); |
| 2371 __ xor_(eax, eax); | 2388 __ xor_(eax, eax); |
| 2372 __ bind(&positive_smi); | 2389 __ bind(&positive_smi); |
| (...skipping 3131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5504 return_value_operand, NULL); | 5521 return_value_operand, NULL); |
| 5505 } | 5522 } |
| 5506 | 5523 |
| 5507 | 5524 |
| 5508 #undef __ | 5525 #undef __ |
| 5509 | 5526 |
| 5510 } // namespace internal | 5527 } // namespace internal |
| 5511 } // namespace v8 | 5528 } // namespace v8 |
| 5512 | 5529 |
| 5513 #endif // V8_TARGET_ARCH_X87 | 5530 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |