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

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

Issue 10837165: Lattice-based representation inference, powered by left/right specific type feedback for BinaryOps … (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback; fixed tests Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/ic-ia32.cc ('k') | src/ia32/lithium-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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 for (current_instruction_ = 0; 295 for (current_instruction_ = 0;
296 !is_aborted() && current_instruction_ < instructions_->length(); 296 !is_aborted() && current_instruction_ < instructions_->length();
297 current_instruction_++) { 297 current_instruction_++) {
298 LInstruction* instr = instructions_->at(current_instruction_); 298 LInstruction* instr = instructions_->at(current_instruction_);
299 if (instr->IsLabel()) { 299 if (instr->IsLabel()) {
300 LLabel* label = LLabel::cast(instr); 300 LLabel* label = LLabel::cast(instr);
301 emit_instructions = !label->HasReplacement(); 301 emit_instructions = !label->HasReplacement();
302 } 302 }
303 303
304 if (emit_instructions) { 304 if (emit_instructions) {
305 Comment(";;; @%d: %s.", current_instruction_, instr->Mnemonic()); 305 if (FLAG_code_comments) {
306 HValue* hydrogen = instr->hydrogen_value();
307 if (hydrogen != NULL) {
308 if (hydrogen->IsChange()) {
309 HValue* changed_value = HChange::cast(hydrogen)->value();
310 int use_id = 0;
311 const char* use_mnemo = "dead";
312 if (hydrogen->UseCount() >= 1) {
313 HValue* use_value = hydrogen->uses().value();
314 use_id = use_value->id();
315 use_mnemo = use_value->Mnemonic();
316 }
317 Comment(";;; @%d: %s. <of #%d %s for #%d %s>",
318 current_instruction_, instr->Mnemonic(),
319 changed_value->id(), changed_value->Mnemonic(),
320 use_id, use_mnemo);
321 } else {
322 Comment(";;; @%d: %s. <#%d>", current_instruction_,
323 instr->Mnemonic(), hydrogen->id());
324 }
325 } else {
326 Comment(";;; @%d: %s.", current_instruction_, instr->Mnemonic());
327 }
328 }
306 instr->CompileToNative(this); 329 instr->CompileToNative(this);
307 } 330 }
308 } 331 }
309 EnsureSpaceForLazyDeopt(); 332 EnsureSpaceForLazyDeopt();
310 return !is_aborted(); 333 return !is_aborted();
311 } 334 }
312 335
313 336
314 bool LCodeGen::GenerateDeferredCode() { 337 bool LCodeGen::GenerateDeferredCode() {
315 ASSERT(is_generating()); 338 ASSERT(is_generating());
(...skipping 4088 matching lines...) Expand 10 before | Expand all | Expand 10 after
4404 4427
4405 // Heap number map check. 4428 // Heap number map check.
4406 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset), 4429 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset),
4407 factory()->heap_number_map()); 4430 factory()->heap_number_map());
4408 4431
4409 if (instr->truncating()) { 4432 if (instr->truncating()) {
4410 __ j(equal, &heap_number, Label::kNear); 4433 __ j(equal, &heap_number, Label::kNear);
4411 // Check for undefined. Undefined is converted to zero for truncating 4434 // Check for undefined. Undefined is converted to zero for truncating
4412 // conversions. 4435 // conversions.
4413 __ cmp(input_reg, factory()->undefined_value()); 4436 __ cmp(input_reg, factory()->undefined_value());
4437 __ RecordComment("Deferred TaggedToI: cannot truncate");
4414 DeoptimizeIf(not_equal, instr->environment()); 4438 DeoptimizeIf(not_equal, instr->environment());
4415 __ mov(input_reg, 0); 4439 __ mov(input_reg, 0);
4416 __ jmp(&done, Label::kNear); 4440 __ jmp(&done, Label::kNear);
4417 4441
4418 __ bind(&heap_number); 4442 __ bind(&heap_number);
4419 if (CpuFeatures::IsSupported(SSE3)) { 4443 if (CpuFeatures::IsSupported(SSE3)) {
4420 CpuFeatures::Scope scope(SSE3); 4444 CpuFeatures::Scope scope(SSE3);
4421 Label convert; 4445 Label convert;
4422 // Use more powerful conversion when sse3 is available. 4446 // Use more powerful conversion when sse3 is available.
4423 // Load x87 register with heap number. 4447 // Load x87 register with heap number.
4424 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset)); 4448 __ fld_d(FieldOperand(input_reg, HeapNumber::kValueOffset));
4425 // Get exponent alone and check for too-big exponent. 4449 // Get exponent alone and check for too-big exponent.
4426 __ mov(input_reg, FieldOperand(input_reg, HeapNumber::kExponentOffset)); 4450 __ mov(input_reg, FieldOperand(input_reg, HeapNumber::kExponentOffset));
4427 __ and_(input_reg, HeapNumber::kExponentMask); 4451 __ and_(input_reg, HeapNumber::kExponentMask);
4428 const uint32_t kTooBigExponent = 4452 const uint32_t kTooBigExponent =
4429 (HeapNumber::kExponentBias + 63) << HeapNumber::kExponentShift; 4453 (HeapNumber::kExponentBias + 63) << HeapNumber::kExponentShift;
4430 __ cmp(Operand(input_reg), Immediate(kTooBigExponent)); 4454 __ cmp(Operand(input_reg), Immediate(kTooBigExponent));
4431 __ j(less, &convert, Label::kNear); 4455 __ j(less, &convert, Label::kNear);
4432 // Pop FPU stack before deoptimizing. 4456 // Pop FPU stack before deoptimizing.
4433 __ fstp(0); 4457 __ fstp(0);
4458 __ RecordComment("Deferred TaggedToI: exponent too big");
4434 DeoptimizeIf(no_condition, instr->environment()); 4459 DeoptimizeIf(no_condition, instr->environment());
4435 4460
4436 // Reserve space for 64 bit answer. 4461 // Reserve space for 64 bit answer.
4437 __ bind(&convert); 4462 __ bind(&convert);
4438 __ sub(Operand(esp), Immediate(kDoubleSize)); 4463 __ sub(Operand(esp), Immediate(kDoubleSize));
4439 // Do conversion, which cannot fail because we checked the exponent. 4464 // Do conversion, which cannot fail because we checked the exponent.
4440 __ fisttp_d(Operand(esp, 0)); 4465 __ fisttp_d(Operand(esp, 0));
4441 __ mov(input_reg, Operand(esp, 0)); // Low word of answer is the result. 4466 __ mov(input_reg, Operand(esp, 0)); // Low word of answer is the result.
4442 __ add(Operand(esp), Immediate(kDoubleSize)); 4467 __ add(Operand(esp), Immediate(kDoubleSize));
4443 } else { 4468 } else {
4444 XMMRegister xmm_temp = ToDoubleRegister(instr->temp()); 4469 XMMRegister xmm_temp = ToDoubleRegister(instr->temp());
4445 __ movdbl(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); 4470 __ movdbl(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
4446 __ cvttsd2si(input_reg, Operand(xmm0)); 4471 __ cvttsd2si(input_reg, Operand(xmm0));
4447 __ cmp(input_reg, 0x80000000u); 4472 __ cmp(input_reg, 0x80000000u);
4448 __ j(not_equal, &done); 4473 __ j(not_equal, &done);
4449 // Check if the input was 0x8000000 (kMinInt). 4474 // Check if the input was 0x8000000 (kMinInt).
4450 // If no, then we got an overflow and we deoptimize. 4475 // If no, then we got an overflow and we deoptimize.
4451 ExternalReference min_int = ExternalReference::address_of_min_int(); 4476 ExternalReference min_int = ExternalReference::address_of_min_int();
4452 __ movdbl(xmm_temp, Operand::StaticVariable(min_int)); 4477 __ movdbl(xmm_temp, Operand::StaticVariable(min_int));
4453 __ ucomisd(xmm_temp, xmm0); 4478 __ ucomisd(xmm_temp, xmm0);
4454 DeoptimizeIf(not_equal, instr->environment()); 4479 DeoptimizeIf(not_equal, instr->environment());
4455 DeoptimizeIf(parity_even, instr->environment()); // NaN. 4480 DeoptimizeIf(parity_even, instr->environment()); // NaN.
4456 } 4481 }
4457 } else { 4482 } else {
4458 // Deoptimize if we don't have a heap number. 4483 // Deoptimize if we don't have a heap number.
4484 __ RecordComment("Deferred TaggedToI: not a heap number");
4459 DeoptimizeIf(not_equal, instr->environment()); 4485 DeoptimizeIf(not_equal, instr->environment());
4460 4486
4461 XMMRegister xmm_temp = ToDoubleRegister(instr->temp()); 4487 XMMRegister xmm_temp = ToDoubleRegister(instr->temp());
4462 __ movdbl(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); 4488 __ movdbl(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
4463 __ cvttsd2si(input_reg, Operand(xmm0)); 4489 __ cvttsd2si(input_reg, Operand(xmm0));
4464 __ cvtsi2sd(xmm_temp, Operand(input_reg)); 4490 __ cvtsi2sd(xmm_temp, Operand(input_reg));
4465 __ ucomisd(xmm0, xmm_temp); 4491 __ ucomisd(xmm0, xmm_temp);
4492 __ RecordComment("Deferred TaggedToI: lost precision");
4466 DeoptimizeIf(not_equal, instr->environment()); 4493 DeoptimizeIf(not_equal, instr->environment());
4494 __ RecordComment("Deferred TaggedToI: NaN");
4467 DeoptimizeIf(parity_even, instr->environment()); // NaN. 4495 DeoptimizeIf(parity_even, instr->environment()); // NaN.
4468 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 4496 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
4469 __ test(input_reg, Operand(input_reg)); 4497 __ test(input_reg, Operand(input_reg));
4470 __ j(not_zero, &done); 4498 __ j(not_zero, &done);
4471 __ movmskpd(input_reg, xmm0); 4499 __ movmskpd(input_reg, xmm0);
4472 __ and_(input_reg, 1); 4500 __ and_(input_reg, 1);
4501 __ RecordComment("Deferred TaggedToI: minus zero");
4473 DeoptimizeIf(not_zero, instr->environment()); 4502 DeoptimizeIf(not_zero, instr->environment());
4474 } 4503 }
4475 } 4504 }
4476 __ bind(&done); 4505 __ bind(&done);
4477 } 4506 }
4478 4507
4479 4508
4480 void LCodeGen::DoTaggedToI(LTaggedToI* instr) { 4509 void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
4481 class DeferredTaggedToI: public LDeferredCode { 4510 class DeferredTaggedToI: public LDeferredCode {
4482 public: 4511 public:
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
5581 FixedArray::kHeaderSize - kPointerSize)); 5610 FixedArray::kHeaderSize - kPointerSize));
5582 __ bind(&done); 5611 __ bind(&done);
5583 } 5612 }
5584 5613
5585 5614
5586 #undef __ 5615 #undef __
5587 5616
5588 } } // namespace v8::internal 5617 } } // namespace v8::internal
5589 5618
5590 #endif // V8_TARGET_ARCH_IA32 5619 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/ic-ia32.cc ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698