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

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: MIPS port 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/ia32/macro-assembler-ia32.h » ('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 #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 Register function = edi;
2270 Register vector = ebx;
2271 Register slot = edx;
2272
2273 Register temp = eax;
2274 XMMRegister xmm_temp1 = xmm0;
2275 XMMRegister xmm_temp2 = xmm1;
2276 Label tail, miss;
2277
2278 // Ensure nobody has snuck in another function.
2279 __ BranchIfNotBuiltin(function, temp, kMathRound, &miss);
2280
2281 if (arg_count() > 0) {
2282 ExternalReference minus_one_half =
2283 ExternalReference::address_of_minus_one_half();
2284
2285 __ mov(temp, Operand(esp, arg_count() * kPointerSize));
2286 Handle<Map> map = isolate()->factory()->heap_number_map();
2287 __ CheckMap(temp, map, &tail, DO_SMI_CHECK);
2288
2289 // If the number is positive, it doesn't round to -0
2290 __ movsd(xmm_temp1, FieldOperand(eax, HeapNumber::kValueOffset));
2291
2292 // If the number is >0, it doesn't round to -0
2293 __ xorps(xmm_temp2, xmm_temp2);
2294 __ ucomisd(xmm_temp1, xmm_temp2);
2295 __ j(above, &tail, Label::kNear);
2296
2297 // If the number is <-.5, it doesn't round to -0
2298 __ movsd(xmm_temp2, Operand::StaticVariable(minus_one_half));
2299 __ ucomisd(xmm_temp1, xmm_temp2);
2300 __ j(below, &tail, Label::kNear);
2301
2302 // The only positive result remaining is 0, it doesn't round to -0..
2303 __ movmskpd(temp, xmm_temp1);
2304 __ test(temp, Immediate(1));
2305 __ j(zero, &tail, Label::kNear);
2306
2307 __ mov(FieldOperand(vector, slot, times_half_pointer_size,
2308 FixedArray::kHeaderSize + kPointerSize),
2309 Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel)));
2310 }
2311
2312 __ bind(&tail);
2313 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod());
2314
2315 // Unreachable.
2316 __ int3();
2317
2318 __ bind(&miss);
2319 GenerateMiss(masm);
2320 __ jmp(&tail);
2321 }
2322
2323
2324 void CallIC_FloorStub::Generate(MacroAssembler* masm) {
2325 Register function = edi;
2326 Register vector = ebx;
2327 Register slot = edx;
2328
2329 Register temp = eax;
2330 Label tail, miss;
2331
2332 // Ensure nobody has snuck in another function.
2333 __ BranchIfNotBuiltin(function, temp, kMathFloor, &miss);
2334
2335 if (arg_count() > 0) {
2336 __ mov(temp, Operand(esp, arg_count() * kPointerSize));
2337 Handle<Map> map = isolate()->factory()->heap_number_map();
2338 __ CheckMap(temp, map, &tail, DO_SMI_CHECK);
2339
2340 // The only number that floors to -0 is -0.
2341 __ cmp(FieldOperand(temp, HeapNumber::kExponentOffset),
2342 Immediate(0x80000000));
2343 __ j(not_equal, &tail);
2344
2345 __ cmp(FieldOperand(temp, HeapNumber::kMantissaOffset), Immediate(0));
2346 __ j(not_equal, &tail);
2347
2348 __ mov(FieldOperand(vector, slot, times_half_pointer_size,
2349 FixedArray::kHeaderSize + kPointerSize),
2350 Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel)));
2351 }
2352
2353 __ bind(&tail);
2354 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod());
2355
2356 // Unreachable.
2357 __ int3();
2358
2359 __ bind(&miss);
2360 GenerateMiss(masm);
2361 __ jmp(&tail);
2362 }
2363
2364
2365 void CallIC_CeilStub::Generate(MacroAssembler* masm) {
2366 Register function = edi;
2367 Register vector = ebx;
2368 Register slot = edx;
2369
2370 Register temp = eax;
2371 XMMRegister xmm_temp1 = xmm0;
2372 XMMRegister xmm_temp2 = xmm1;
2373 Label tail, miss;
2374
2375 // Ensure nobody has snuck in another function.
2376 __ BranchIfNotBuiltin(function, temp, kMathCeil, &miss);
2377
2378 if (arg_count() > 0) {
2379 ExternalReference minus_one = ExternalReference::address_of_minus_one();
2380
2381 __ mov(temp, Operand(esp, arg_count() * kPointerSize));
2382 Handle<Map> map = isolate()->factory()->heap_number_map();
2383 __ CheckMap(temp, map, &tail, DO_SMI_CHECK);
2384
2385 __ movsd(xmm_temp1, FieldOperand(eax, HeapNumber::kValueOffset));
2386
2387 // If the number is >0, it doesn't round to -0
2388 __ xorps(xmm_temp2, xmm_temp2);
2389 __ ucomisd(xmm_temp1, xmm_temp2);
2390 __ j(greater, &tail, Label::kNear);
2391
2392 // If the number is <=-1, it doesn't round to -0
2393 __ movsd(xmm_temp2, Operand::StaticVariable(minus_one));
2394 __ ucomisd(xmm_temp1, xmm_temp2);
2395 __ j(less_equal, &tail, Label::kNear);
2396
2397 // The only positive result remaining is 0, it doesn't round to -0..
2398 __ movmskpd(temp, xmm_temp1);
2399 __ test(temp, Immediate(1));
2400 __ j(zero, &tail, Label::kNear);
2401
2402 __ mov(FieldOperand(vector, slot, times_half_pointer_size,
2403 FixedArray::kHeaderSize + kPointerSize),
2404 Immediate(Smi::FromInt(kHasReturnedMinusZeroSentinel)));
2405 }
2406
2407 __ bind(&tail);
2408 CallFunctionNoFeedback(masm, arg_count(), true, CallAsMethod());
2409
2410 // Unreachable.
2411 __ int3();
2412
2413 __ bind(&miss);
2414 GenerateMiss(masm);
2415 __ jmp(&tail);
2416 }
2417
2418
2268 void CallICStub::Generate(MacroAssembler* masm) { 2419 void CallICStub::Generate(MacroAssembler* masm) {
2269 // edi - function 2420 // edi - function
2270 // edx - slot id 2421 // edx - slot id
2271 // ebx - vector 2422 // ebx - vector
2272 Isolate* isolate = masm->isolate(); 2423 Isolate* isolate = masm->isolate();
2273 const int with_types_offset = 2424 const int with_types_offset =
2274 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); 2425 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex);
2275 const int generic_offset = 2426 const int generic_offset =
2276 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); 2427 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex);
2277 Label extra_checks_or_miss, slow_start; 2428 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. 2517 // Goto miss case if we do not have a function.
2367 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2518 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
2368 __ j(not_equal, &miss); 2519 __ j(not_equal, &miss);
2369 2520
2370 // Make sure the function is not the Array() function, which requires special 2521 // Make sure the function is not the Array() function, which requires special
2371 // behavior on MISS. 2522 // behavior on MISS.
2372 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 2523 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
2373 __ cmp(edi, ecx); 2524 __ cmp(edi, ecx);
2374 __ j(equal, &miss); 2525 __ j(equal, &miss);
2375 2526
2527 // Make sure that the function is not Math.floor, Math.round or Math.ceil
2528 // which have special CallICs to handle -0.0.
2529 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
2530 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset));
2531 __ cmp(eax, Immediate(Smi::FromInt(0)));
2532 __ j(not_equal, &miss);
2533
2376 // Update stats. 2534 // Update stats.
2377 __ add(FieldOperand(ebx, with_types_offset), Immediate(Smi::FromInt(1))); 2535 __ add(FieldOperand(ebx, with_types_offset), Immediate(Smi::FromInt(1)));
2378 2536
2379 // Store the function. Use a stub since we need a frame for allocation. 2537 // Store the function. Use a stub since we need a frame for allocation.
2380 // ebx - vector 2538 // ebx - vector
2381 // edx - slot 2539 // edx - slot
2382 // edi - function 2540 // edi - function
2383 { 2541 {
2384 FrameScope scope(masm, StackFrame::INTERNAL); 2542 FrameScope scope(masm, StackFrame::INTERNAL);
2385 CreateWeakCellStub create_stub(isolate); 2543 CreateWeakCellStub create_stub(isolate);
(...skipping 2255 matching lines...) Expand 10 before | Expand all | Expand 10 after
4641 } 4799 }
4642 4800
4643 4801
4644 void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) { 4802 void CallIC_ArrayTrampolineStub::Generate(MacroAssembler* masm) {
4645 EmitLoadTypeFeedbackVector(masm, ebx); 4803 EmitLoadTypeFeedbackVector(masm, ebx);
4646 CallIC_ArrayStub stub(isolate(), state()); 4804 CallIC_ArrayStub stub(isolate(), state());
4647 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET); 4805 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4648 } 4806 }
4649 4807
4650 4808
4809 void CallIC_RoundTrampolineStub::Generate(MacroAssembler* masm) {
4810 EmitLoadTypeFeedbackVector(masm, ebx);
4811 CallIC_RoundStub stub(isolate(), state());
4812 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4813 }
4814
4815
4816 void CallIC_FloorTrampolineStub::Generate(MacroAssembler* masm) {
4817 EmitLoadTypeFeedbackVector(masm, ebx);
4818 CallIC_FloorStub stub(isolate(), state());
4819 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4820 }
4821
4822
4823 void CallIC_CeilTrampolineStub::Generate(MacroAssembler* masm) {
4824 EmitLoadTypeFeedbackVector(masm, ebx);
4825 CallIC_CeilStub stub(isolate(), state());
4826 __ jmp(stub.GetCode(), RelocInfo::CODE_TARGET);
4827 }
4828
4829
4651 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) { 4830 void ProfileEntryHookStub::MaybeCallEntryHook(MacroAssembler* masm) {
4652 if (masm->isolate()->function_entry_hook() != NULL) { 4831 if (masm->isolate()->function_entry_hook() != NULL) {
4653 ProfileEntryHookStub stub(masm->isolate()); 4832 ProfileEntryHookStub stub(masm->isolate());
4654 masm->CallStub(&stub); 4833 masm->CallStub(&stub);
4655 } 4834 }
4656 } 4835 }
4657 4836
4658 4837
4659 void ProfileEntryHookStub::Generate(MacroAssembler* masm) { 4838 void ProfileEntryHookStub::Generate(MacroAssembler* masm) {
4660 // Save volatile registers. 4839 // Save volatile registers.
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
5407 ApiParameterOperand(2), kStackSpace, nullptr, 5586 ApiParameterOperand(2), kStackSpace, nullptr,
5408 Operand(ebp, 7 * kPointerSize), NULL); 5587 Operand(ebp, 7 * kPointerSize), NULL);
5409 } 5588 }
5410 5589
5411 5590
5412 #undef __ 5591 #undef __
5413 5592
5414 } } // namespace v8::internal 5593 } } // namespace v8::internal
5415 5594
5416 #endif // V8_TARGET_ARCH_IA32 5595 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698