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

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

Issue 163153002: introduce LTaggedToSmi (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 10 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/ia32/lithium-codegen-ia32.h ('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 5299 matching lines...) Expand 10 before | Expand all | Expand 10 after
5310 DeferredTaggedToI* deferred = 5310 DeferredTaggedToI* deferred =
5311 new(zone()) DeferredTaggedToI(this, instr, x87_stack_); 5311 new(zone()) DeferredTaggedToI(this, instr, x87_stack_);
5312 5312
5313 __ JumpIfNotSmi(input_reg, deferred->entry()); 5313 __ JumpIfNotSmi(input_reg, deferred->entry());
5314 __ SmiUntag(input_reg); 5314 __ SmiUntag(input_reg);
5315 __ bind(deferred->exit()); 5315 __ bind(deferred->exit());
5316 } 5316 }
5317 } 5317 }
5318 5318
5319 5319
5320 void LCodeGen::DoDeferredTaggedToSmi(LTaggedToSmi* instr, Label* done) {
5321 Register input_reg = ToRegister(instr->value());
5322
5323 if (instr->truncating()) {
5324 Label no_heap_number, check_bools, check_false;
5325
5326 // Heap number map check.
5327 __ cmp(FieldOperand(input_reg, HeapObject::kMapOffset),
5328 factory()->heap_number_map());
5329 __ j(not_equal, &no_heap_number, Label::kNear);
5330 __ TruncateHeapNumberToI(input_reg, input_reg);
5331 __ SmiTag(input_reg);
5332 DeoptimizeIf(overflow, instr->environment());
5333 __ jmp(done);
5334
5335 __ bind(&no_heap_number);
5336 // Check for Oddballs. Undefined/False is converted to zero and True to one
5337 // for truncating conversions.
5338 __ cmp(input_reg, factory()->undefined_value());
5339 __ j(not_equal, &check_bools, Label::kNear);
5340 __ Set(input_reg, Immediate(0));
5341 __ jmp(done);
5342
5343 __ bind(&check_bools);
5344 __ cmp(input_reg, factory()->true_value());
5345 __ j(not_equal, &check_false, Label::kNear);
5346 __ Set(input_reg, Immediate(2));
5347 __ jmp(done);
5348
5349 __ bind(&check_false);
5350 __ cmp(input_reg, factory()->false_value());
5351 __ RecordComment("Deferred TaggedToI: cannot truncate");
5352 DeoptimizeIf(not_equal, instr->environment());
5353 __ Set(input_reg, Immediate(0));
5354 __ jmp(done);
5355 } else {
5356 Label bailout;
5357 XMMRegister scratch = (instr->temp() != NULL)
5358 ? ToDoubleRegister(instr->temp())
5359 : no_xmm_reg;
5360 __ TaggedToI(input_reg, input_reg, scratch,
5361 instr->hydrogen()->GetMinusZeroMode(), &bailout);
5362 __ SmiTag(input_reg);
5363 DeoptimizeIf(overflow, instr->environment());
5364 __ jmp(done);
5365 __ bind(&bailout);
5366 DeoptimizeIf(no_condition, instr->environment());
5367 }
5368 }
5369
5370
5371 void LCodeGen::DoTaggedToSmi(LTaggedToSmi* instr) {
5372 class DeferredTaggedToSmi V8_FINAL : public LDeferredCode {
5373 public:
5374 DeferredTaggedToSmi(LCodeGen* codegen,
5375 LTaggedToSmi* instr,
5376 const X87Stack& x87_stack)
5377 : LDeferredCode(codegen, x87_stack), instr_(instr) { }
5378 virtual void Generate() V8_OVERRIDE {
5379 codegen()->DoDeferredTaggedToSmi(instr_, done());
5380 }
5381 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
5382 private:
5383 LTaggedToSmi* instr_;
5384 };
5385
5386 LOperand* input = instr->value();
5387 ASSERT(input->IsRegister());
5388 Register input_reg = ToRegister(input);
5389 ASSERT(input_reg.is(ToRegister(instr->result())));
5390
5391 if (!instr->hydrogen()->value()->representation().IsSmi()) {
5392 DeferredTaggedToSmi* deferred =
5393 new(zone()) DeferredTaggedToSmi(this, instr, x87_stack_);
5394
5395 __ JumpIfNotSmi(input_reg, deferred->entry());
5396 __ bind(deferred->exit());
5397 }
5398 }
5399
5400
5320 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) { 5401 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) {
5321 LOperand* input = instr->value(); 5402 LOperand* input = instr->value();
5322 ASSERT(input->IsRegister()); 5403 ASSERT(input->IsRegister());
5323 LOperand* temp = instr->temp(); 5404 LOperand* temp = instr->temp();
5324 ASSERT(temp->IsRegister()); 5405 ASSERT(temp->IsRegister());
5325 LOperand* result = instr->result(); 5406 LOperand* result = instr->result();
5326 ASSERT(result->IsDoubleRegister()); 5407 ASSERT(result->IsDoubleRegister());
5327 5408
5328 Register input_reg = ToRegister(input); 5409 Register input_reg = ToRegister(input);
5329 bool deoptimize_on_minus_zero = 5410 bool deoptimize_on_minus_zero =
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
5395 } 5476 }
5396 5477
5397 5478
5398 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { 5479 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) {
5399 LOperand* input = instr->value(); 5480 LOperand* input = instr->value();
5400 ASSERT(input->IsDoubleRegister()); 5481 ASSERT(input->IsDoubleRegister());
5401 LOperand* result = instr->result(); 5482 LOperand* result = instr->result();
5402 ASSERT(result->IsRegister()); 5483 ASSERT(result->IsRegister());
5403 Register result_reg = ToRegister(result); 5484 Register result_reg = ToRegister(result);
5404 5485
5405 Label bailout, done; 5486 if (instr->truncating()) {
5406 if (CpuFeatures::IsSafeForSnapshot(SSE2)) { 5487 if (CpuFeatures::IsSafeForSnapshot(SSE2)) {
5407 CpuFeatureScope scope(masm(), SSE2); 5488 CpuFeatureScope scope(masm(), SSE2);
5408 XMMRegister input_reg = ToDoubleRegister(input); 5489 XMMRegister input_reg = ToDoubleRegister(input);
5409 XMMRegister xmm_scratch = double_scratch0(); 5490 __ TruncateDoubleToI(result_reg, input_reg);
5410 __ DoubleToI(result_reg, input_reg, xmm_scratch, 5491 } else {
5411 instr->hydrogen()->GetMinusZeroMode(), &bailout, Label::kNear); 5492 X87Register input_reg = ToX87Register(input);
5493 X87Fxch(input_reg);
5494 __ TruncateX87TOSToI(result_reg);
5495 }
5412 } else { 5496 } else {
5413 X87Register input_reg = ToX87Register(input); 5497 Label bailout, done;
5414 X87Fxch(input_reg); 5498 if (CpuFeatures::IsSafeForSnapshot(SSE2)) {
5415 __ X87TOSToI(result_reg, instr->hydrogen()->GetMinusZeroMode(), 5499 CpuFeatureScope scope(masm(), SSE2);
5416 &bailout, Label::kNear); 5500 XMMRegister input_reg = ToDoubleRegister(input);
5501 XMMRegister xmm_scratch = double_scratch0();
5502 __ DoubleToI(result_reg, input_reg, xmm_scratch,
5503 instr->hydrogen()->GetMinusZeroMode(), &bailout, Label::kNear);
5504 } else {
5505 X87Register input_reg = ToX87Register(input);
5506 X87Fxch(input_reg);
5507 __ X87TOSToI(result_reg, instr->hydrogen()->GetMinusZeroMode(),
5508 &bailout, Label::kNear);
5509 }
5510 __ jmp(&done, Label::kNear);
5511 __ bind(&bailout);
5512 DeoptimizeIf(no_condition, instr->environment());
5513 __ bind(&done);
5417 } 5514 }
5418 __ jmp(&done, Label::kNear);
5419 __ bind(&bailout);
5420 DeoptimizeIf(no_condition, instr->environment());
5421 __ bind(&done);
5422 5515
5423 __ SmiTag(result_reg); 5516 __ SmiTag(result_reg);
5424 DeoptimizeIf(overflow, instr->environment()); 5517 DeoptimizeIf(overflow, instr->environment());
5425 } 5518 }
5426 5519
5427 5520
5428 void LCodeGen::DoCheckSmi(LCheckSmi* instr) { 5521 void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
5429 LOperand* input = instr->value(); 5522 LOperand* input = instr->value();
5430 __ test(ToOperand(input), Immediate(kSmiTagMask)); 5523 __ test(ToOperand(input), Immediate(kSmiTagMask));
5431 DeoptimizeIf(not_zero, instr->environment()); 5524 DeoptimizeIf(not_zero, instr->environment());
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
6266 FixedArray::kHeaderSize - kPointerSize)); 6359 FixedArray::kHeaderSize - kPointerSize));
6267 __ bind(&done); 6360 __ bind(&done);
6268 } 6361 }
6269 6362
6270 6363
6271 #undef __ 6364 #undef __
6272 6365
6273 } } // namespace v8::internal 6366 } } // namespace v8::internal
6274 6367
6275 #endif // V8_TARGET_ARCH_IA32 6368 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698