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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 Label patch; | 242 Label patch; |
243 Factory* factory = masm->isolate()->factory(); | 243 Factory* factory = masm->isolate()->factory(); |
244 const Register argument = eax; | 244 const Register argument = eax; |
245 const Register map = edx; | 245 const Register map = edx; |
246 | 246 |
247 if (!types_.IsEmpty()) { | 247 if (!types_.IsEmpty()) { |
248 __ mov(argument, Operand(esp, 1 * kPointerSize)); | 248 __ mov(argument, Operand(esp, 1 * kPointerSize)); |
249 } | 249 } |
250 | 250 |
251 // undefined -> false | 251 // undefined -> false |
252 CheckOddball(masm, UNDEFINED, factory->undefined_value(), false, &patch); | 252 CheckOddball(masm, UNDEFINED, Heap::kUndefinedValueRootIndex, false, &patch); |
253 | 253 |
254 // Boolean -> its value | 254 // Boolean -> its value |
255 CheckOddball(masm, BOOLEAN, factory->false_value(), false, &patch); | 255 CheckOddball(masm, BOOLEAN, Heap::kFalseValueRootIndex, false, &patch); |
256 CheckOddball(masm, BOOLEAN, factory->true_value(), true, &patch); | 256 CheckOddball(masm, BOOLEAN, Heap::kTrueValueRootIndex, true, &patch); |
257 | 257 |
258 // 'null' -> false. | 258 // 'null' -> false.!!! |
Kevin Millikin (Chromium)
2011/08/01 13:02:05
Don't be so surprised, it's JavaScript :)
Sven Panne
2011/08/01 13:13:25
Ooops, a leftover from a previous debugging sessio
| |
259 CheckOddball(masm, NULL_TYPE, factory->null_value(), false, &patch); | 259 CheckOddball(masm, NULL_TYPE, Heap::kNullValueRootIndex, false, &patch); |
260 | 260 |
261 if (types_.Contains(SMI)) { | 261 if (types_.Contains(SMI)) { |
262 // Smis: 0 -> false, all other -> true | 262 // Smis: 0 -> false, all other -> true |
263 Label not_smi; | 263 Label not_smi; |
264 __ JumpIfNotSmi(argument, ¬_smi, Label::kNear); | 264 __ JumpIfNotSmi(argument, ¬_smi, Label::kNear); |
265 // argument contains the correct return value already | 265 // argument contains the correct return value already |
266 if (!tos_.is(argument)) { | 266 if (!tos_.is(argument)) { |
267 __ mov(tos_, argument); | 267 __ mov(tos_, argument); |
268 } | 268 } |
269 __ ret(1 * kPointerSize); | 269 __ ret(1 * kPointerSize); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
344 | 344 |
345 if (!types_.IsAll()) { | 345 if (!types_.IsAll()) { |
346 __ bind(&patch); | 346 __ bind(&patch); |
347 GenerateTypeTransition(masm); | 347 GenerateTypeTransition(masm); |
348 } | 348 } |
349 } | 349 } |
350 | 350 |
351 | 351 |
352 void ToBooleanStub::CheckOddball(MacroAssembler* masm, | 352 void ToBooleanStub::CheckOddball(MacroAssembler* masm, |
353 Type type, | 353 Type type, |
354 Handle<Object> value, | 354 Heap::RootListIndex value, |
355 bool result, | 355 bool result, |
356 Label* patch) { | 356 Label* patch) { |
357 const Register argument = eax; | 357 const Register argument = eax; |
358 if (types_.Contains(type)) { | 358 if (types_.Contains(type)) { |
359 // If we see an expected oddball, return its ToBoolean value tos_. | 359 // If we see an expected oddball, return its ToBoolean value tos_. |
360 Label different_value; | 360 Label different_value; |
361 __ cmp(argument, value); | 361 __ CompareRoot(argument, value); |
362 __ j(not_equal, &different_value, Label::kNear); | 362 __ j(not_equal, &different_value, Label::kNear); |
363 __ Set(tos_, Immediate(result ? 1 : 0)); | 363 __ Set(tos_, Immediate(result ? 1 : 0)); |
364 __ ret(1 * kPointerSize); | 364 __ ret(1 * kPointerSize); |
365 __ bind(&different_value); | 365 __ bind(&different_value); |
366 } else if (types_.Contains(INTERNAL_OBJECT)) { | 366 } else if (types_.Contains(INTERNAL_OBJECT)) { |
367 // If we see an unexpected oddball and handle internal objects, we must | 367 // If we see an unexpected oddball and handle internal objects, we must |
368 // patch because the code for internal objects doesn't handle it explictly. | 368 // patch because the code for internal objects doesn't handle it explictly. |
369 __ cmp(argument, value); | 369 __ CompareRoot(argument, value); |
370 __ j(equal, patch); | 370 __ j(equal, patch); |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 | 374 |
375 void ToBooleanStub::GenerateTypeTransition(MacroAssembler* masm) { | 375 void ToBooleanStub::GenerateTypeTransition(MacroAssembler* masm) { |
376 __ pop(ecx); // Get return address, operand is now on top of stack. | 376 __ pop(ecx); // Get return address, operand is now on top of stack. |
377 __ push(Immediate(Smi::FromInt(tos_.code()))); | 377 __ push(Immediate(Smi::FromInt(tos_.code()))); |
378 __ push(Immediate(Smi::FromInt(types_.ToByte()))); | 378 __ push(Immediate(Smi::FromInt(types_.ToByte()))); |
379 __ push(ecx); // Push return address. | 379 __ push(ecx); // Push return address. |
(...skipping 5997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6377 __ Drop(1); | 6377 __ Drop(1); |
6378 __ ret(2 * kPointerSize); | 6378 __ ret(2 * kPointerSize); |
6379 } | 6379 } |
6380 | 6380 |
6381 | 6381 |
6382 #undef __ | 6382 #undef __ |
6383 | 6383 |
6384 } } // namespace v8::internal | 6384 } } // namespace v8::internal |
6385 | 6385 |
6386 #endif // V8_TARGET_ARCH_IA32 | 6386 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |