OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 __ b(eq, &is_smi); | 1254 __ b(eq, &is_smi); |
1255 __ ldr(r1, MemOperand(r0, HeapObject::kMapOffset - kHeapObjectTag)); | 1255 __ ldr(r1, MemOperand(r0, HeapObject::kMapOffset - kHeapObjectTag)); |
1256 __ ldrb(r1, MemOperand(r1, Map::kInstanceTypeOffset - kHeapObjectTag)); | 1256 __ ldrb(r1, MemOperand(r1, Map::kInstanceTypeOffset - kHeapObjectTag)); |
1257 __ cmp(r1, Operand(HEAP_NUMBER_TYPE)); | 1257 __ cmp(r1, Operand(HEAP_NUMBER_TYPE)); |
1258 __ b(ne, fail_label); | 1258 __ b(ne, fail_label); |
1259 __ push(r0); | 1259 __ push(r0); |
1260 __ CallRuntime(Runtime::kNumberToSmi, 1); | 1260 __ CallRuntime(Runtime::kNumberToSmi, 1); |
1261 __ bind(&is_smi); | 1261 __ bind(&is_smi); |
1262 | 1262 |
1263 if (min_index != 0) { | 1263 if (min_index != 0) { |
1264 // small positive numbers can be immediate operands. | 1264 // Small positive numbers can be immediate operands. |
1265 if (min_index < 0) { | 1265 if (min_index < 0) { |
1266 __ add(r0, r0, Operand(Smi::FromInt(-min_index))); | 1266 // If min_index is Smi::kMinValue, -min_index is not a Smi. |
| 1267 if (Smi::IsValid(-min_index)) { |
| 1268 __ add(r0, r0, Operand(Smi::FromInt(-min_index))); |
| 1269 } else { |
| 1270 __ add(r0, r0, Operand(Smi::FromInt(-min_index - 1))); |
| 1271 __ add(r0, r0, Operand(Smi::FromInt(1))); |
| 1272 } |
1267 } else { | 1273 } else { |
1268 __ sub(r0, r0, Operand(Smi::FromInt(min_index))); | 1274 __ sub(r0, r0, Operand(Smi::FromInt(min_index))); |
1269 } | 1275 } |
1270 } | 1276 } |
1271 __ tst(r0, Operand(0x80000000 | kSmiTagMask)); | 1277 __ tst(r0, Operand(0x80000000 | kSmiTagMask)); |
1272 __ b(ne, fail_label); | 1278 __ b(ne, fail_label); |
1273 __ cmp(r0, Operand(Smi::FromInt(range))); | 1279 __ cmp(r0, Operand(Smi::FromInt(range))); |
1274 __ b(ge, fail_label); | 1280 __ b(ge, fail_label); |
1275 __ add(pc, pc, Operand(r0, LSL, 2 - kSmiTagSize)); | 1281 __ add(pc, pc, Operand(r0, LSL, 2 - kSmiTagSize)); |
1276 // One extra instruction offsets the table, so the table's start address is | 1282 // One extra instruction offsets the table, so the table's start address is |
1277 // the pc-register at the above add. | 1283 // the pc-register at the above add. |
1278 __ stop("Unreachable: Switch table alignment"); | 1284 __ stop("Unreachable: Switch table alignment"); |
1279 | 1285 |
1280 // table containing branch operations. | 1286 // Table containing branch operations. |
1281 for (int i = 0; i < range; i++) { | 1287 for (int i = 0; i < range; i++) { |
1282 __ b(case_targets[i]); | 1288 __ b(case_targets[i]); |
1283 } | 1289 } |
1284 | 1290 |
1285 GenerateFastCaseSwitchCases(node, case_labels); | 1291 GenerateFastCaseSwitchCases(node, case_labels); |
1286 } | 1292 } |
1287 | 1293 |
1288 | 1294 |
1289 void CodeGenerator::VisitSwitchStatement(SwitchStatement* node) { | 1295 void CodeGenerator::VisitSwitchStatement(SwitchStatement* node) { |
1290 Comment cmnt(masm_, "[ SwitchStatement"); | 1296 Comment cmnt(masm_, "[ SwitchStatement"); |
(...skipping 2932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4223 // Slow-case: Non-function called. | 4229 // Slow-case: Non-function called. |
4224 __ bind(&slow); | 4230 __ bind(&slow); |
4225 __ mov(r0, Operand(argc_)); // Setup the number of arguments. | 4231 __ mov(r0, Operand(argc_)); // Setup the number of arguments. |
4226 __ InvokeBuiltin(Builtins::CALL_NON_FUNCTION, JUMP_JS); | 4232 __ InvokeBuiltin(Builtins::CALL_NON_FUNCTION, JUMP_JS); |
4227 } | 4233 } |
4228 | 4234 |
4229 | 4235 |
4230 #undef __ | 4236 #undef __ |
4231 | 4237 |
4232 } } // namespace v8::internal | 4238 } } // namespace v8::internal |
OLD | NEW |