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

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

Issue 1053143005: Collect type feedback on result of Math.[round|ceil|floor] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tweaks Created 5 years, 7 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/hydrogen.cc ('k') | src/ic/ic.cc » ('j') | src/ic/ic.cc » ('J')
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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #if V8_TARGET_ARCH_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 2247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 CallFunctionNoFeedback(masm, 2258 CallFunctionNoFeedback(masm,
2259 arg_count(), 2259 arg_count(),
2260 true, 2260 true,
2261 CallAsMethod()); 2261 CallAsMethod());
2262 2262
2263 // Unreachable. 2263 // Unreachable.
2264 __ int3(); 2264 __ int3();
2265 } 2265 }
2266 2266
2267 2267
2268 void CallIC_RoundStub::Generate(MacroAssembler* masm) {
2269 // edi - function
2270 // edx - slot id
2271 // ebx - vector
2272
2273 Label slow, miss;
2274
2275 // Ensure nobody has snuck in another function.
2276 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2277 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset));
2278 __ cmp(eax, Immediate(Smi::FromInt(kMathRound)));
2279 __ j(not_equal, &miss);
2280
2281 if (arg_count() > 0) {
2282 Register output_reg = eax;
2283 XMMRegister input_reg = xmm1;
2284 XMMRegister xmm_scratch = xmm0;
2285 ExternalReference minus_one_half =
2286 ExternalReference::address_of_minus_one_half();
2287
2288 __ mov(eax, Operand(esp, arg_count() * kPointerSize));
2289 Handle<Map> map = isolate()->factory()->heap_number_map();
2290 __ CheckMap(eax, map, &slow, DO_SMI_CHECK);
2291
2292 // If the number is positive, it doesn't round to -0
2293 __ movsd(input_reg, FieldOperand(eax, HeapNumber::kValueOffset));
2294
2295 __ xorps(xmm_scratch, xmm_scratch);
2296 __ ucomisd(input_reg, xmm_scratch);
2297 __ j(above, &slow, Label::kNear);
2298
2299 __ movsd(xmm_scratch, Operand::StaticVariable(minus_one_half));
2300 __ ucomisd(input_reg, xmm_scratch);
2301 __ j(below, &slow, Label::kNear);
2302
2303 // The only positive result remaining is 0, don't set the sentinel.
2304 __ movmskpd(output_reg, input_reg);
2305 __ test(output_reg, Immediate(1));
2306 __ j(zero, &slow, Label::kNear);
2307
2308 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
2309 FixedArray::kHeaderSize + kPointerSize),
2310 Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel)));
2311 }
2312
2313 __ bind(&slow);
2314 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod());
2315
2316 __ bind(&miss);
2317 GenerateMiss(masm);
2318 // The slow case, we need this no matter what to complete a call after a miss.
2319 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod());
2320
2321 // Unreachable.
2322 __ int3();
2323 }
2324
2325
2326 void CallIC_FloorStub::Generate(MacroAssembler* masm) {
2327 // edi - function
2328 // edx - slot id
2329 // ebx - vector
2330
2331 Label slow, miss;
2332
2333 // Ensure nobody has snuck in another function.
2334 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2335 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset));
2336 __ cmp(eax, Immediate(Smi::FromInt(kMathFloor)));
2337 __ j(not_equal, &miss);
2338
2339 if (arg_count() > 0) {
2340 __ mov(eax, Operand(esp, arg_count() * kPointerSize));
2341 Handle<Map> map = isolate()->factory()->heap_number_map();
2342 __ CheckMap(eax, map, &slow, DO_SMI_CHECK);
2343
2344 __ cmp(FieldOperand(eax, HeapNumber::kExponentOffset),
2345 Immediate(0x80000000));
2346 __ j(not_equal, &slow);
2347
2348 __ cmp(FieldOperand(eax, HeapNumber::kMantissaOffset), Immediate(0));
2349 __ j(not_equal, &slow);
2350
2351 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
2352 FixedArray::kHeaderSize + kPointerSize),
2353 Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel)));
2354 }
2355
2356 __ bind(&slow);
2357 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod());
2358
2359 __ bind(&miss);
2360 GenerateMiss(masm);
2361 // The slow case, we need this no matter what to complete a call after a miss.
2362 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod());
2363
2364 // Unreachable.
2365 __ int3();
2366 }
2367
2368
2369 void CallIC_CeilStub::Generate(MacroAssembler* masm) {
2370 // edi - function
2371 // edx - slot id
2372 // ebx - vector
2373
2374 Label slow, miss;
2375
2376 // Ensure nobody has snuck in another function.
2377 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
mvstanton 2015/04/28 14:21:20 Since this sequence happens three times, maybe it'
danno 2015/04/30 13:34:32 Done.
2378 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset));
2379 __ cmp(eax, Immediate(Smi::FromInt(kMathCeil)));
2380 __ j(not_equal, &miss);
2381
2382 if (arg_count() > 0) {
2383 Register output_reg = eax;
2384 XMMRegister input_reg = xmm1;
2385 XMMRegister xmm_scratch = xmm0;
2386 ExternalReference minus_one = ExternalReference::address_of_minus_one();
2387
2388 __ mov(eax, Operand(esp, arg_count() * kPointerSize));
2389 Handle<Map> map = isolate()->factory()->heap_number_map();
2390 __ CheckMap(eax, map, &slow, DO_SMI_CHECK);
2391
2392 __ movsd(input_reg, FieldOperand(eax, HeapNumber::kValueOffset));
2393
2394 __ xorps(xmm_scratch, xmm_scratch);
2395 __ ucomisd(input_reg, xmm_scratch);
2396 __ j(greater, &slow, Label::kNear);
2397
2398 __ movsd(xmm_scratch, Operand::StaticVariable(minus_one));
2399 __ ucomisd(input_reg, xmm_scratch);
2400 __ j(less_equal, &slow, Label::kNear);
2401
2402 // If the number is positive, it doesn't round to -0
2403 __ movmskpd(output_reg, input_reg);
2404 __ test(output_reg, Immediate(1));
2405 __ j(zero, &slow, Label::kNear);
2406
2407 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
2408 FixedArray::kHeaderSize + kPointerSize),
2409 Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel)));
2410 }
2411
2412 __ bind(&slow);
2413 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod());
2414
2415 __ bind(&miss);
2416 GenerateMiss(masm);
2417 // The slow case, we need this no matter what to complete a call after a miss.
2418 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod());
2419
2420 // Unreachable.
2421 __ int3();
2422 }
2423
2424
2268 void CallICStub::Generate(MacroAssembler* masm) { 2425 void CallICStub::Generate(MacroAssembler* masm) {
2269 // edi - function 2426 // edi - function
2270 // edx - slot id 2427 // edx - slot id
2271 // ebx - vector 2428 // ebx - vector
2272 Isolate* isolate = masm->isolate(); 2429 Isolate* isolate = masm->isolate();
2273 const int with_types_offset = 2430 const int with_types_offset =
2274 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); 2431 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex);
2275 const int generic_offset = 2432 const int generic_offset =
2276 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); 2433 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex);
2277 Label extra_checks_or_miss, slow_start; 2434 Label extra_checks_or_miss, slow_start;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 // Goto miss case if we do not have a function. 2523 // Goto miss case if we do not have a function.
2367 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2524 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
2368 __ j(not_equal, &miss); 2525 __ j(not_equal, &miss);
2369 2526
2370 // Make sure the function is not the Array() function, which requires special 2527 // Make sure the function is not the Array() function, which requires special
2371 // behavior on MISS. 2528 // behavior on MISS.
2372 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 2529 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
2373 __ cmp(edi, ecx); 2530 __ cmp(edi, ecx);
2374 __ j(equal, &miss); 2531 __ j(equal, &miss);
2375 2532
2533 // Make sure that the function is not Math.floor, Math.round or Math.ceil
2534 // which have special CallICs to handle -0.0.
2535 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2536 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset));
2537 __ cmp(eax, Immediate(Smi::FromInt(kMathRound)));
mvstanton 2015/04/28 14:21:20 Maybe it's okay to go to the miss handler if it's
danno 2015/04/30 13:34:32 Done.
2538 __ j(equal, &miss);
2539 __ cmp(eax, Immediate(Smi::FromInt(kMathFloor)));
2540 __ j(equal, &miss);
2541 __ cmp(eax, Immediate(Smi::FromInt(kMathCeil)));
2542 __ j(equal, &miss);
2543
2376 // Update stats. 2544 // Update stats.
2377 __ add(FieldOperand(ebx, with_types_offset), Immediate(Smi::FromInt(1))); 2545 __ add(FieldOperand(ebx, with_types_offset), Immediate(Smi::FromInt(1)));
2378 2546
2379 // Store the function. Use a stub since we need a frame for allocation. 2547 // Store the function. Use a stub since we need a frame for allocation.
2380 // ebx - vector 2548 // ebx - vector
2381 // edx - slot 2549 // edx - slot
2382 // edi - function 2550 // edi - function
2383 { 2551 {
2384 FrameScope scope(masm, StackFrame::INTERNAL); 2552 FrameScope scope(masm, StackFrame::INTERNAL);
2385 CreateWeakCellStub create_stub(isolate); 2553 CreateWeakCellStub create_stub(isolate);
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after
4641 } 4809 }
4642 4810
4643 4811
4644 void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) { 4812 void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) {
4645 EmitLoadTypeFeedbackVector(masm, ebx); 4813 EmitLoadTypeFeedbackVector(masm, ebx);
4646 CallIC_ArrayStub stub(isolate(), state()); 4814 CallIC_ArrayStub stub(isolate(), state());
4647 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); 4815 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4648 } 4816 }
4649 4817
4650 4818
4819 void CallIC_RoundTrampolineStub::Generate(MacroAssembler* masm) {
4820 EmitLoadTypeFeedbackVector(masm, ebx);
4821 CallIC_RoundStub stub(isolate(), state());
4822 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4823 }
4824
4825
4826 void CallIC_FloorTrampolineStub::Generate(MacroAssembler* masm) {
4827 EmitLoadTypeFeedbackVector(masm, ebx);
4828 CallIC_FloorStub stub(isolate(), state());
4829 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4830 }
4831
4832
4833 void CallIC_CeilTrampolineStub::Generate(MacroAssembler* masm) {
4834 EmitLoadTypeFeedbackVector(masm, ebx);
4835 CallIC_CeilStub stub(isolate(), state());
4836 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4837 }
4838
4839
4651 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { 4840 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
4652 if (masm->isolate()->function_entry_hook() != NULL) { 4841 if (masm->isolate()->function_entry_hook() != NULL) {
4653 ProfileEntryHookStub stub(masm->isolate()); 4842 ProfileEntryHookStub stub(masm->isolate());
4654 masm->CallStub(&stub); 4843 masm->CallStub(&stub);
4655 } 4844 }
4656 } 4845 }
4657 4846
4658 4847
4659 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { 4848 void ProfileEntryHookStub::Generate(MacroAssembler* masm) {
4660 // Save volatile registers. 4849 // Save volatile registers.
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
5407 ApiParameterOperand(2), kStackSpace, nullptr, 5596 ApiParameterOperand(2), kStackSpace, nullptr,
5408 Operand(ebp, 7 * kPointerSize), NULL); 5597 Operand(ebp, 7 * kPointerSize), NULL);
5409 } 5598 }
5410 5599
5411 5600
5412 #undef __ 5601 #undef __
5413 5602
5414 } } // namespace v8::internal 5603 } } // namespace v8::internal
5415 5604
5416 #endif // V8_TARGET_ARCH_IA32 5605 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/ic/ic.cc » ('j') | src/ic/ic.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698