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

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 7218012: Make ToBooleanStub more consistent across platforms. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/x64/code-stubs-x64.h ('k') | src/x64/full-codegen-x64.cc » ('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 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 224 }
225 225
226 // Return and remove the on-stack parameters. 226 // Return and remove the on-stack parameters.
227 __ ret(3 * kPointerSize); 227 __ ret(3 * kPointerSize);
228 228
229 __ bind(&slow_case); 229 __ bind(&slow_case);
230 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); 230 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1);
231 } 231 }
232 232
233 233
234 // The stub returns zero for false, and a non-zero value for true.
234 void ToBooleanStub::Generate(MacroAssembler* masm) { 235 void ToBooleanStub::Generate(MacroAssembler* masm) {
235 Label false_result, true_result, not_string; 236 Label false_result, true_result, not_string;
237 const Register map = rdx;
238
236 __ movq(rax, Operand(rsp, 1 * kPointerSize)); 239 __ movq(rax, Operand(rsp, 1 * kPointerSize));
237 240
238 // undefined -> false 241 // undefined -> false
239 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex); 242 __ CompareRoot(rax, Heap::kUndefinedValueRootIndex);
240 __ j(equal, &false_result); 243 __ j(equal, &false_result);
241 244
242 // Boolean -> its value 245 // Boolean -> its value
243 __ CompareRoot(rax, Heap::kFalseValueRootIndex); 246 __ CompareRoot(rax, Heap::kFalseValueRootIndex);
244 __ j(equal, &false_result); 247 __ j(equal, &false_result);
245 __ CompareRoot(rax, Heap::kTrueValueRootIndex); 248 __ CompareRoot(rax, Heap::kTrueValueRootIndex);
246 __ j(equal, &true_result); 249 __ j(equal, &true_result);
247 250
248 // Smis: 0 -> false, all other -> true 251 // Smis: 0 -> false, all other -> true
249 __ Cmp(rax, Smi::FromInt(0)); 252 __ Cmp(rax, Smi::FromInt(0));
250 __ j(equal, &false_result); 253 __ j(equal, &false_result);
251 __ JumpIfSmi(rax, &true_result); 254 __ JumpIfSmi(rax, &true_result);
252 255
253 // 'null' => false. 256 // 'null' -> false.
254 __ CompareRoot(rax, Heap::kNullValueRootIndex); 257 __ CompareRoot(rax, Heap::kNullValueRootIndex);
255 __ j(equal, &false_result, Label::kNear); 258 __ j(equal, &false_result, Label::kNear);
256 259
257 // Get the map and type of the heap object. 260 // Get the map of the heap object.
258 // We don't use CmpObjectType because we manipulate the type field. 261 __ movq(map, FieldOperand(rax, HeapObject::kMapOffset));
259 __ movq(rdx, FieldOperand(rax, HeapObject::kMapOffset));
260 __ movzxbq(rcx, FieldOperand(rdx, Map::kInstanceTypeOffset));
261 262
262 // Undetectable => false. 263 // Undetectable -> false.
263 __ movzxbq(rbx, FieldOperand(rdx, Map::kBitFieldOffset)); 264 __ testb(FieldOperand(map, Map::kBitFieldOffset),
264 __ and_(rbx, Immediate(1 << Map::kIsUndetectable)); 265 Immediate(1 << Map::kIsUndetectable));
265 __ j(not_zero, &false_result, Label::kNear); 266 __ j(not_zero, &false_result, Label::kNear);
266 267
267 // JavaScript object => true. 268 // JavaScript object -> true.
268 __ cmpq(rcx, Immediate(FIRST_SPEC_OBJECT_TYPE)); 269 __ CmpInstanceType(map, FIRST_SPEC_OBJECT_TYPE);
269 __ j(above_equal, &true_result, Label::kNear); 270 __ j(above_equal, &true_result, Label::kNear);
270 271
271 // String value => false iff empty. 272 // String value -> false iff empty.
272 __ cmpq(rcx, Immediate(FIRST_NONSTRING_TYPE)); 273 __ CmpInstanceType(map, FIRST_NONSTRING_TYPE);
273 __ j(above_equal, &not_string, Label::kNear); 274 __ j(above_equal, &not_string, Label::kNear);
274 __ movq(rdx, FieldOperand(rax, String::kLengthOffset)); 275 __ cmpq(FieldOperand(rax, String::kLengthOffset), Immediate(0));
275 __ SmiTest(rdx);
276 __ j(zero, &false_result, Label::kNear); 276 __ j(zero, &false_result, Label::kNear);
277 __ jmp(&true_result, Label::kNear); 277 __ jmp(&true_result, Label::kNear);
278 278
279 __ bind(&not_string); 279 __ bind(&not_string);
280 __ CompareRoot(rdx, Heap::kHeapNumberMapRootIndex); 280 // HeapNumber -> false iff +0, -0, or NaN.
281 // These three cases set the zero flag when compared to zero using ucomisd.
282 __ CompareRoot(map, Heap::kHeapNumberMapRootIndex);
281 __ j(not_equal, &true_result, Label::kNear); 283 __ j(not_equal, &true_result, Label::kNear);
282 // HeapNumber => false iff +0, -0, or NaN.
283 // These three cases set the zero flag when compared to zero using ucomisd.
284 __ xorps(xmm0, xmm0); 284 __ xorps(xmm0, xmm0);
285 __ ucomisd(xmm0, FieldOperand(rax, HeapNumber::kValueOffset)); 285 __ ucomisd(xmm0, FieldOperand(rax, HeapNumber::kValueOffset));
286 __ j(zero, &false_result, Label::kNear); 286 __ j(zero, &false_result, Label::kNear);
287 // Fall through to |true_result|. 287 // Fall through to |true_result|.
288 288
289 // Return 1/0 for true/false in rax. 289 // Return 1/0 for true/false in tos_.
290 __ bind(&true_result); 290 __ bind(&true_result);
291 __ Set(rax, 1); 291 __ Set(tos_, 1);
292 __ ret(1 * kPointerSize); 292 __ ret(1 * kPointerSize);
293 __ bind(&false_result); 293 __ bind(&false_result);
294 __ Set(rax, 0); 294 __ Set(tos_, 0);
295 __ ret(1 * kPointerSize); 295 __ ret(1 * kPointerSize);
296 } 296 }
297 297
298 298
299 class FloatingPointHelper : public AllStatic { 299 class FloatingPointHelper : public AllStatic {
300 public: 300 public:
301 // Load the operands from rdx and rax into xmm0 and xmm1, as doubles. 301 // Load the operands from rdx and rax into xmm0 and xmm1, as doubles.
302 // If the operands are not both numbers, jump to not_numbers. 302 // If the operands are not both numbers, jump to not_numbers.
303 // Leaves rdx and rax unchanged. SmiOperands assumes both are smis. 303 // Leaves rdx and rax unchanged. SmiOperands assumes both are smis.
304 // NumberOperands assumes both are smis or heap numbers. 304 // NumberOperands assumes both are smis or heap numbers.
(...skipping 5035 matching lines...) Expand 10 before | Expand all | Expand 10 after
5340 __ Drop(1); 5340 __ Drop(1);
5341 __ ret(2 * kPointerSize); 5341 __ ret(2 * kPointerSize);
5342 } 5342 }
5343 5343
5344 5344
5345 #undef __ 5345 #undef __
5346 5346
5347 } } // namespace v8::internal 5347 } } // namespace v8::internal
5348 5348
5349 #endif // V8_TARGET_ARCH_X64 5349 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698