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

Side by Side Diff: src/ia32/code-stubs-ia32.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/ia32/code-stubs-ia32.h ('k') | src/ia32/full-codegen-ia32.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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 230 }
231 231
232 // Return and remove the on-stack parameters. 232 // Return and remove the on-stack parameters.
233 __ ret(3 * kPointerSize); 233 __ ret(3 * kPointerSize);
234 234
235 __ bind(&slow_case); 235 __ bind(&slow_case);
236 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); 236 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1);
237 } 237 }
238 238
239 239
240 // NOTE: The stub does not handle the inlined cases (Smis, Booleans, undefined). 240 // The stub returns zero for false, and a non-zero value for true.
241 void ToBooleanStub::Generate(MacroAssembler* masm) { 241 void ToBooleanStub::Generate(MacroAssembler* masm) {
242 Label false_result, true_result, not_string; 242 Label false_result, true_result, not_string;
243 Factory* factory = masm->isolate()->factory();
244 const Register map = edx;
245
243 __ mov(eax, Operand(esp, 1 * kPointerSize)); 246 __ mov(eax, Operand(esp, 1 * kPointerSize));
244 Factory* factory = masm->isolate()->factory();
245 247
246 // undefined -> false 248 // undefined -> false
247 __ cmp(eax, factory->undefined_value()); 249 __ cmp(eax, factory->undefined_value());
248 __ j(equal, &false_result); 250 __ j(equal, &false_result);
249 251
250 // Boolean -> its value 252 // Boolean -> its value
253 __ cmp(eax, factory->false_value());
254 __ j(equal, &false_result);
251 __ cmp(eax, factory->true_value()); 255 __ cmp(eax, factory->true_value());
252 __ j(equal, &true_result); 256 __ j(equal, &true_result);
253 __ cmp(eax, factory->false_value());
254 __ j(equal, &false_result);
255 257
256 // Smis: 0 -> false, all other -> true 258 // Smis: 0 -> false, all other -> true
257 __ test(eax, Operand(eax)); 259 __ test(eax, Operand(eax));
258 __ j(zero, &false_result); 260 __ j(zero, &false_result);
259 __ JumpIfSmi(eax, &true_result); 261 __ JumpIfSmi(eax, &true_result);
260 262
261 // 'null' => false. 263 // 'null' -> false.
262 __ cmp(eax, factory->null_value()); 264 __ cmp(eax, factory->null_value());
263 __ j(equal, &false_result, Label::kNear); 265 __ j(equal, &false_result, Label::kNear);
264 266
265 // Get the map and type of the heap object. 267 // Get the map of the heap object.
266 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); 268 __ mov(map, FieldOperand(eax, HeapObject::kMapOffset));
267 __ movzx_b(ecx, FieldOperand(edx, Map::kInstanceTypeOffset));
268 269
269 // Undetectable => false. 270 // Undetectable -> false.
270 __ test_b(FieldOperand(edx, Map::kBitFieldOffset), 271 __ test_b(FieldOperand(map, Map::kBitFieldOffset),
271 1 << Map::kIsUndetectable); 272 1 << Map::kIsUndetectable);
272 __ j(not_zero, &false_result, Label::kNear); 273 __ j(not_zero, &false_result, Label::kNear);
273 274
274 // JavaScript object => true. 275 // JavaScript object -> true.
275 __ CmpInstanceType(edx, FIRST_SPEC_OBJECT_TYPE); 276 __ CmpInstanceType(map, FIRST_SPEC_OBJECT_TYPE);
276 __ j(above_equal, &true_result, Label::kNear); 277 __ j(above_equal, &true_result, Label::kNear);
277 278
278 // String value => false iff empty. 279 // String value -> false iff empty.
279 __ CmpInstanceType(edx, FIRST_NONSTRING_TYPE); 280 __ CmpInstanceType(map, FIRST_NONSTRING_TYPE);
280 __ j(above_equal, &not_string, Label::kNear); 281 __ j(above_equal, &not_string, Label::kNear);
281 STATIC_ASSERT(kSmiTag == 0);
282 __ cmp(FieldOperand(eax, String::kLengthOffset), Immediate(0)); 282 __ cmp(FieldOperand(eax, String::kLengthOffset), Immediate(0));
283 __ j(zero, &false_result, Label::kNear); 283 __ j(zero, &false_result, Label::kNear);
284 __ jmp(&true_result, Label::kNear); 284 __ jmp(&true_result, Label::kNear);
285 285
286 __ bind(&not_string); 286 __ bind(&not_string);
287 // HeapNumber => false iff +0, -0, or NaN. 287 // HeapNumber -> false iff +0, -0, or NaN.
288 __ cmp(edx, factory->heap_number_map()); 288 __ cmp(map, factory->heap_number_map());
289 __ j(not_equal, &true_result, Label::kNear); 289 __ j(not_equal, &true_result, Label::kNear);
290 __ fldz(); 290 __ fldz();
291 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset)); 291 __ fld_d(FieldOperand(eax, HeapNumber::kValueOffset));
292 __ FCmp(); 292 __ FCmp();
293 __ j(zero, &false_result, Label::kNear); 293 __ j(zero, &false_result, Label::kNear);
294 // Fall through to |true_result|. 294 // Fall through to |true_result|.
295 295
296 // Return 1/0 for true/false in eax. 296 // Return 1/0 for true/false in tos_.
297 __ bind(&true_result); 297 __ bind(&true_result);
298 __ mov(eax, 1); 298 __ mov(tos_, 1);
299 __ ret(1 * kPointerSize); 299 __ ret(1 * kPointerSize);
300 __ bind(&false_result); 300 __ bind(&false_result);
301 __ mov(eax, 0); 301 __ mov(tos_, 0);
302 __ ret(1 * kPointerSize); 302 __ ret(1 * kPointerSize);
303 } 303 }
304 304
305 305
306 class FloatingPointHelper : public AllStatic { 306 class FloatingPointHelper : public AllStatic {
307 public: 307 public:
308 enum ArgLocation { 308 enum ArgLocation {
309 ARGS_ON_STACK, 309 ARGS_ON_STACK,
310 ARGS_IN_REGISTERS 310 ARGS_IN_REGISTERS
311 }; 311 };
(...skipping 6037 matching lines...) Expand 10 before | Expand all | Expand 10 after
6349 __ Drop(1); 6349 __ Drop(1);
6350 __ ret(2 * kPointerSize); 6350 __ ret(2 * kPointerSize);
6351 } 6351 }
6352 6352
6353 6353
6354 #undef __ 6354 #undef __
6355 6355
6356 } } // namespace v8::internal 6356 } } // namespace v8::internal
6357 6357
6358 #endif // V8_TARGET_ARCH_IA32 6358 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.h ('k') | src/ia32/full-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698