OLD | NEW |
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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 ASSERT(op->IsRegister()); | 285 ASSERT(op->IsRegister()); |
286 return ToRegister(op->index()); | 286 return ToRegister(op->index()); |
287 } | 287 } |
288 | 288 |
289 | 289 |
290 Register LCodeGen::EmitLoadRegister(LOperand* op, Register scratch) { | 290 Register LCodeGen::EmitLoadRegister(LOperand* op, Register scratch) { |
291 if (op->IsRegister()) { | 291 if (op->IsRegister()) { |
292 return ToRegister(op->index()); | 292 return ToRegister(op->index()); |
293 } else if (op->IsConstantOperand()) { | 293 } else if (op->IsConstantOperand()) { |
294 LConstantOperand* const_op = LConstantOperand::cast(op); | 294 LConstantOperand* const_op = LConstantOperand::cast(op); |
295 Handle<Object> literal = chunk_->LookupLiteral(const_op); | 295 HConstant* constant = chunk_->LookupConstant(const_op); |
| 296 Handle<Object> literal = constant->handle(); |
296 Representation r = chunk_->LookupLiteralRepresentation(const_op); | 297 Representation r = chunk_->LookupLiteralRepresentation(const_op); |
297 if (r.IsInteger32()) { | 298 if (r.IsInteger32()) { |
298 ASSERT(literal->IsNumber()); | 299 ASSERT(literal->IsNumber()); |
299 __ li(scratch, Operand(static_cast<int32_t>(literal->Number()))); | 300 __ li(scratch, Operand(static_cast<int32_t>(literal->Number()))); |
300 } else if (r.IsDouble()) { | 301 } else if (r.IsDouble()) { |
301 Abort("EmitLoadRegister: Unsupported double immediate."); | 302 Abort("EmitLoadRegister: Unsupported double immediate."); |
302 } else { | 303 } else { |
303 ASSERT(r.IsTagged()); | 304 ASSERT(r.IsTagged()); |
304 if (literal->IsSmi()) { | 305 if (literal->IsSmi()) { |
305 __ li(scratch, Operand(literal)); | 306 __ li(scratch, Operand(literal)); |
(...skipping 17 matching lines...) Expand all Loading... |
323 } | 324 } |
324 | 325 |
325 | 326 |
326 DoubleRegister LCodeGen::EmitLoadDoubleRegister(LOperand* op, | 327 DoubleRegister LCodeGen::EmitLoadDoubleRegister(LOperand* op, |
327 FloatRegister flt_scratch, | 328 FloatRegister flt_scratch, |
328 DoubleRegister dbl_scratch) { | 329 DoubleRegister dbl_scratch) { |
329 if (op->IsDoubleRegister()) { | 330 if (op->IsDoubleRegister()) { |
330 return ToDoubleRegister(op->index()); | 331 return ToDoubleRegister(op->index()); |
331 } else if (op->IsConstantOperand()) { | 332 } else if (op->IsConstantOperand()) { |
332 LConstantOperand* const_op = LConstantOperand::cast(op); | 333 LConstantOperand* const_op = LConstantOperand::cast(op); |
333 Handle<Object> literal = chunk_->LookupLiteral(const_op); | 334 HConstant* constant = chunk_->LookupConstant(const_op); |
| 335 Handle<Object> literal = constant->handle(); |
334 Representation r = chunk_->LookupLiteralRepresentation(const_op); | 336 Representation r = chunk_->LookupLiteralRepresentation(const_op); |
335 if (r.IsInteger32()) { | 337 if (r.IsInteger32()) { |
336 ASSERT(literal->IsNumber()); | 338 ASSERT(literal->IsNumber()); |
337 __ li(at, Operand(static_cast<int32_t>(literal->Number()))); | 339 __ li(at, Operand(static_cast<int32_t>(literal->Number()))); |
338 __ mtc1(at, flt_scratch); | 340 __ mtc1(at, flt_scratch); |
339 __ cvt_d_w(dbl_scratch, flt_scratch); | 341 __ cvt_d_w(dbl_scratch, flt_scratch); |
340 return dbl_scratch; | 342 return dbl_scratch; |
341 } else if (r.IsDouble()) { | 343 } else if (r.IsDouble()) { |
342 Abort("unsupported double immediate"); | 344 Abort("unsupported double immediate"); |
343 } else if (r.IsTagged()) { | 345 } else if (r.IsTagged()) { |
344 Abort("unsupported tagged immediate"); | 346 Abort("unsupported tagged immediate"); |
345 } | 347 } |
346 } else if (op->IsStackSlot() || op->IsArgument()) { | 348 } else if (op->IsStackSlot() || op->IsArgument()) { |
347 MemOperand mem_op = ToMemOperand(op); | 349 MemOperand mem_op = ToMemOperand(op); |
348 __ ldc1(dbl_scratch, mem_op); | 350 __ ldc1(dbl_scratch, mem_op); |
349 return dbl_scratch; | 351 return dbl_scratch; |
350 } | 352 } |
351 UNREACHABLE(); | 353 UNREACHABLE(); |
352 return dbl_scratch; | 354 return dbl_scratch; |
353 } | 355 } |
354 | 356 |
355 | 357 |
356 Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const { | 358 Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const { |
357 Handle<Object> literal = chunk_->LookupLiteral(op); | 359 HConstant* constant = chunk_->LookupConstant(op); |
358 ASSERT(chunk_->LookupLiteralRepresentation(op).IsTagged()); | 360 ASSERT(chunk_->LookupLiteralRepresentation(op).IsTagged()); |
359 return literal; | 361 return constant->handle(); |
360 } | 362 } |
361 | 363 |
362 | 364 |
363 bool LCodeGen::IsInteger32(LConstantOperand* op) const { | 365 bool LCodeGen::IsInteger32(LConstantOperand* op) const { |
364 return chunk_->LookupLiteralRepresentation(op).IsInteger32(); | 366 return chunk_->LookupLiteralRepresentation(op).IsInteger32(); |
365 } | 367 } |
366 | 368 |
367 | 369 |
368 int LCodeGen::ToInteger32(LConstantOperand* op) const { | 370 int LCodeGen::ToInteger32(LConstantOperand* op) const { |
369 Handle<Object> value = chunk_->LookupLiteral(op); | 371 HConstant* constant = chunk_->LookupConstant(op); |
370 ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32()); | 372 ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32()); |
371 ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) == | 373 ASSERT(constant->HasInteger32Value()); |
372 value->Number()); | 374 return constant->Integer32Value(); |
373 return static_cast<int32_t>(value->Number()); | |
374 } | 375 } |
375 | 376 |
376 | 377 |
377 double LCodeGen::ToDouble(LConstantOperand* op) const { | 378 double LCodeGen::ToDouble(LConstantOperand* op) const { |
378 Handle<Object> value = chunk_->LookupLiteral(op); | 379 HConstant* constant = chunk_->LookupConstant(op); |
379 return value->Number(); | 380 ASSERT(constant->HasDoubleValue()); |
| 381 return constant->DoubleValue(); |
380 } | 382 } |
381 | 383 |
382 | 384 |
383 Operand LCodeGen::ToOperand(LOperand* op) { | 385 Operand LCodeGen::ToOperand(LOperand* op) { |
384 if (op->IsConstantOperand()) { | 386 if (op->IsConstantOperand()) { |
385 LConstantOperand* const_op = LConstantOperand::cast(op); | 387 LConstantOperand* const_op = LConstantOperand::cast(op); |
386 Handle<Object> literal = chunk_->LookupLiteral(const_op); | 388 HConstant* constant = chunk()->LookupConstant(const_op); |
387 Representation r = chunk_->LookupLiteralRepresentation(const_op); | 389 Representation r = chunk_->LookupLiteralRepresentation(const_op); |
388 if (r.IsInteger32()) { | 390 if (r.IsInteger32()) { |
389 ASSERT(literal->IsNumber()); | 391 ASSERT(constant->HasInteger32Value()); |
390 return Operand(static_cast<int32_t>(literal->Number())); | 392 return Operand(constant->Integer32Value()); |
391 } else if (r.IsDouble()) { | 393 } else if (r.IsDouble()) { |
392 Abort("ToOperand Unsupported double immediate."); | 394 Abort("ToOperand Unsupported double immediate."); |
393 } | 395 } |
394 ASSERT(r.IsTagged()); | 396 ASSERT(r.IsTagged()); |
395 return Operand(literal); | 397 return Operand(constant->handle()); |
396 } else if (op->IsRegister()) { | 398 } else if (op->IsRegister()) { |
397 return Operand(ToRegister(op)); | 399 return Operand(ToRegister(op)); |
398 } else if (op->IsDoubleRegister()) { | 400 } else if (op->IsDoubleRegister()) { |
399 Abort("ToOperand IsDoubleRegister unimplemented"); | 401 Abort("ToOperand IsDoubleRegister unimplemented"); |
400 return Operand(0); | 402 return Operand(0); |
401 } | 403 } |
402 // Stack slots not implemented, use ToMemOperand instead. | 404 // Stack slots not implemented, use ToMemOperand instead. |
403 UNREACHABLE(); | 405 UNREACHABLE(); |
404 return Operand(0); | 406 return Operand(0); |
405 } | 407 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 Register reg = ToRegister(op); | 516 Register reg = ToRegister(op); |
515 if (is_tagged) { | 517 if (is_tagged) { |
516 translation->StoreRegister(reg); | 518 translation->StoreRegister(reg); |
517 } else { | 519 } else { |
518 translation->StoreInt32Register(reg); | 520 translation->StoreInt32Register(reg); |
519 } | 521 } |
520 } else if (op->IsDoubleRegister()) { | 522 } else if (op->IsDoubleRegister()) { |
521 DoubleRegister reg = ToDoubleRegister(op); | 523 DoubleRegister reg = ToDoubleRegister(op); |
522 translation->StoreDoubleRegister(reg); | 524 translation->StoreDoubleRegister(reg); |
523 } else if (op->IsConstantOperand()) { | 525 } else if (op->IsConstantOperand()) { |
524 Handle<Object> literal = chunk()->LookupLiteral(LConstantOperand::cast(op)); | 526 HConstant* constant = chunk()->LookupConstant(LConstantOperand::cast(op)); |
525 int src_index = DefineDeoptimizationLiteral(literal); | 527 int src_index = DefineDeoptimizationLiteral(constant->handle()); |
526 translation->StoreLiteral(src_index); | 528 translation->StoreLiteral(src_index); |
527 } else { | 529 } else { |
528 UNREACHABLE(); | 530 UNREACHABLE(); |
529 } | 531 } |
530 } | 532 } |
531 | 533 |
532 | 534 |
533 void LCodeGen::CallCode(Handle<Code> code, | 535 void LCodeGen::CallCode(Handle<Code> code, |
534 RelocInfo::Mode mode, | 536 RelocInfo::Mode mode, |
535 LInstruction* instr) { | 537 LInstruction* instr) { |
(...skipping 4668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5204 __ Subu(scratch, result, scratch); | 5206 __ Subu(scratch, result, scratch); |
5205 __ lw(result, FieldMemOperand(scratch, | 5207 __ lw(result, FieldMemOperand(scratch, |
5206 FixedArray::kHeaderSize - kPointerSize)); | 5208 FixedArray::kHeaderSize - kPointerSize)); |
5207 __ bind(&done); | 5209 __ bind(&done); |
5208 } | 5210 } |
5209 | 5211 |
5210 | 5212 |
5211 #undef __ | 5213 #undef __ |
5212 | 5214 |
5213 } } // namespace v8::internal | 5215 } } // namespace v8::internal |
OLD | NEW |