OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 __ bind(&slow_case); | 238 __ bind(&slow_case); |
239 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); | 239 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); |
240 } | 240 } |
241 | 241 |
242 | 242 |
243 // NOTE: The stub does not handle the inlined cases (Smis, Booleans, undefined). | 243 // NOTE: The stub does not handle the inlined cases (Smis, Booleans, undefined). |
244 void ToBooleanStub::Generate(MacroAssembler* masm) { | 244 void ToBooleanStub::Generate(MacroAssembler* masm) { |
245 Label false_result, true_result, not_string; | 245 Label false_result, true_result, not_string; |
246 __ mov(eax, Operand(esp, 1 * kPointerSize)); | 246 __ mov(eax, Operand(esp, 1 * kPointerSize)); |
| 247 Factory* factory = masm->isolate()->factory(); |
| 248 |
| 249 // undefined -> false |
| 250 __ cmp(eax, factory->undefined_value()); |
| 251 __ j(equal, &false_result); |
| 252 |
| 253 // Boolean -> its value |
| 254 __ cmp(eax, factory->true_value()); |
| 255 __ j(equal, &true_result); |
| 256 __ cmp(eax, factory->false_value()); |
| 257 __ j(equal, &false_result); |
| 258 |
| 259 // Smis: 0 -> false, all other -> true |
| 260 __ test(eax, Operand(eax)); |
| 261 __ j(zero, &false_result); |
| 262 __ test(eax, Immediate(kSmiTagMask)); |
| 263 __ j(zero, &true_result); |
247 | 264 |
248 // 'null' => false. | 265 // 'null' => false. |
249 Factory* factory = masm->isolate()->factory(); | |
250 __ cmp(eax, factory->null_value()); | 266 __ cmp(eax, factory->null_value()); |
251 __ j(equal, &false_result, Label::kNear); | 267 __ j(equal, &false_result, Label::kNear); |
252 | 268 |
253 // Get the map and type of the heap object. | 269 // Get the map and type of the heap object. |
254 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); | 270 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); |
255 __ movzx_b(ecx, FieldOperand(edx, Map::kInstanceTypeOffset)); | 271 __ movzx_b(ecx, FieldOperand(edx, Map::kInstanceTypeOffset)); |
256 | 272 |
257 // Undetectable => false. | 273 // Undetectable => false. |
258 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), | 274 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), |
259 1 << Map::kIsUndetectable); | 275 1 << Map::kIsUndetectable); |
(...skipping 5892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6152 __ Drop(1); | 6168 __ Drop(1); |
6153 __ ret(2 * kPointerSize); | 6169 __ ret(2 * kPointerSize); |
6154 } | 6170 } |
6155 | 6171 |
6156 | 6172 |
6157 #undef __ | 6173 #undef __ |
6158 | 6174 |
6159 } } // namespace v8::internal | 6175 } } // namespace v8::internal |
6160 | 6176 |
6161 #endif // V8_TARGET_ARCH_IA32 | 6177 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |