OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 // the map. The object has already been smi checked. | 1396 // the map. The object has already been smi checked. |
1397 Register scratch = ToRegister(instr->temp()); | 1397 Register scratch = ToRegister(instr->temp()); |
1398 __ mov(scratch, FieldOperand(reg, HeapObject::kMapOffset)); | 1398 __ mov(scratch, FieldOperand(reg, HeapObject::kMapOffset)); |
1399 __ movzx_b(scratch, FieldOperand(scratch, Map::kBitFieldOffset)); | 1399 __ movzx_b(scratch, FieldOperand(scratch, Map::kBitFieldOffset)); |
1400 __ test(scratch, Immediate(1 << Map::kIsUndetectable)); | 1400 __ test(scratch, Immediate(1 << Map::kIsUndetectable)); |
1401 EmitBranch(true_block, false_block, not_zero); | 1401 EmitBranch(true_block, false_block, not_zero); |
1402 } | 1402 } |
1403 } | 1403 } |
1404 | 1404 |
1405 | 1405 |
| 1406 Condition LCodeGen::EmitIsObject(Register input, |
| 1407 Register temp1, |
| 1408 Register temp2, |
| 1409 Label* is_not_object, |
| 1410 Label* is_object) { |
| 1411 ASSERT(!input.is(temp1)); |
| 1412 ASSERT(!input.is(temp2)); |
| 1413 ASSERT(!temp1.is(temp2)); |
| 1414 |
| 1415 __ test(input, Immediate(kSmiTagMask)); |
| 1416 __ j(equal, is_not_object); |
| 1417 |
| 1418 __ cmp(input, Factory::null_value()); |
| 1419 __ j(equal, is_object); |
| 1420 |
| 1421 __ mov(temp1, FieldOperand(input, HeapObject::kMapOffset)); |
| 1422 // Undetectable objects behave like undefined. |
| 1423 __ movzx_b(temp2, FieldOperand(temp1, Map::kBitFieldOffset)); |
| 1424 __ test(temp2, Immediate(1 << Map::kIsUndetectable)); |
| 1425 __ j(not_zero, is_not_object); |
| 1426 |
| 1427 __ movzx_b(temp2, FieldOperand(temp1, Map::kInstanceTypeOffset)); |
| 1428 __ cmp(temp2, FIRST_JS_OBJECT_TYPE); |
| 1429 __ j(below, is_not_object); |
| 1430 __ cmp(temp2, LAST_JS_OBJECT_TYPE); |
| 1431 return below_equal; |
| 1432 } |
| 1433 |
| 1434 |
| 1435 void LCodeGen::DoIsObject(LIsObject* instr) { |
| 1436 Register reg = ToRegister(instr->input()); |
| 1437 Register result = ToRegister(instr->result()); |
| 1438 Register temp = ToRegister(instr->temp()); |
| 1439 Label is_false, is_true, done; |
| 1440 |
| 1441 Condition true_cond = EmitIsObject(reg, result, temp, &is_false, &is_true); |
| 1442 __ j(true_cond, &is_true); |
| 1443 |
| 1444 __ bind(&is_false); |
| 1445 __ mov(result, Handle<Object>(Heap::false_value())); |
| 1446 __ jmp(&done); |
| 1447 |
| 1448 __ bind(&is_true); |
| 1449 __ mov(result, Handle<Object>(Heap::true_value())); |
| 1450 |
| 1451 __ bind(&done); |
| 1452 } |
| 1453 |
| 1454 |
| 1455 void LCodeGen::DoIsObjectAndBranch(LIsObjectAndBranch* instr) { |
| 1456 Register reg = ToRegister(instr->input()); |
| 1457 Register temp = ToRegister(instr->temp()); |
| 1458 Register temp2 = ToRegister(instr->temp2()); |
| 1459 |
| 1460 int true_block = chunk_->LookupDestination(instr->true_block_id()); |
| 1461 int false_block = chunk_->LookupDestination(instr->false_block_id()); |
| 1462 Label* true_label = chunk_->GetAssemblyLabel(true_block); |
| 1463 Label* false_label = chunk_->GetAssemblyLabel(false_block); |
| 1464 |
| 1465 Condition true_cond = EmitIsObject(reg, temp, temp2, false_label, true_label); |
| 1466 |
| 1467 EmitBranch(true_block, false_block, true_cond); |
| 1468 } |
| 1469 |
| 1470 |
1406 void LCodeGen::DoIsSmi(LIsSmi* instr) { | 1471 void LCodeGen::DoIsSmi(LIsSmi* instr) { |
1407 Operand input = ToOperand(instr->input()); | 1472 Operand input = ToOperand(instr->input()); |
1408 Register result = ToRegister(instr->result()); | 1473 Register result = ToRegister(instr->result()); |
1409 | 1474 |
1410 ASSERT(instr->hydrogen()->value()->representation().IsTagged()); | 1475 ASSERT(instr->hydrogen()->value()->representation().IsTagged()); |
1411 __ test(input, Immediate(kSmiTagMask)); | 1476 __ test(input, Immediate(kSmiTagMask)); |
1412 __ mov(result, Handle<Object>(Heap::true_value())); | 1477 __ mov(result, Handle<Object>(Heap::true_value())); |
1413 NearLabel done; | 1478 NearLabel done; |
1414 __ j(zero, &done); | 1479 __ j(zero, &done); |
1415 __ mov(result, Handle<Object>(Heap::false_value())); | 1480 __ mov(result, Handle<Object>(Heap::false_value())); |
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3155 ASSERT(!environment->HasBeenRegistered()); | 3220 ASSERT(!environment->HasBeenRegistered()); |
3156 RegisterEnvironmentForDeoptimization(environment); | 3221 RegisterEnvironmentForDeoptimization(environment); |
3157 ASSERT(osr_pc_offset_ == -1); | 3222 ASSERT(osr_pc_offset_ == -1); |
3158 osr_pc_offset_ = masm()->pc_offset(); | 3223 osr_pc_offset_ = masm()->pc_offset(); |
3159 } | 3224 } |
3160 | 3225 |
3161 | 3226 |
3162 #undef __ | 3227 #undef __ |
3163 | 3228 |
3164 } } // namespace v8::internal | 3229 } } // namespace v8::internal |
OLD | NEW |