| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 void ToBooleanStub::PrintName(StringStream* stream) { | 337 void ToBooleanStub::PrintName(StringStream* stream) { |
| 338 stream->Add("ToBooleanStub_"); | 338 stream->Add("ToBooleanStub_"); |
| 339 types_.Print(stream); | 339 types_.Print(stream); |
| 340 } | 340 } |
| 341 | 341 |
| 342 | 342 |
| 343 void ToBooleanStub::Types::Print(StringStream* stream) const { | 343 void ToBooleanStub::Types::Print(StringStream* stream) const { |
| 344 if (IsEmpty()) stream->Add("None"); | 344 if (IsEmpty()) stream->Add("None"); |
| 345 if (Contains(UNDEFINED)) stream->Add("Undefined"); | 345 if (Contains(UNDEFINED)) stream->Add("Undefined"); |
| 346 if (Contains(BOOLEAN)) stream->Add("Bool"); | 346 if (Contains(BOOLEAN)) stream->Add("Bool"); |
| 347 if (Contains(NULL_TYPE)) stream->Add("Null"); |
| 347 if (Contains(SMI)) stream->Add("Smi"); | 348 if (Contains(SMI)) stream->Add("Smi"); |
| 348 if (Contains(NULL_TYPE)) stream->Add("Null"); | |
| 349 if (Contains(SPEC_OBJECT)) stream->Add("SpecObject"); | 349 if (Contains(SPEC_OBJECT)) stream->Add("SpecObject"); |
| 350 if (Contains(STRING)) stream->Add("String"); | 350 if (Contains(STRING)) stream->Add("String"); |
| 351 if (Contains(HEAP_NUMBER)) stream->Add("HeapNumber"); | 351 if (Contains(HEAP_NUMBER)) stream->Add("HeapNumber"); |
| 352 if (Contains(INTERNAL_OBJECT)) stream->Add("InternalObject"); | |
| 353 } | 352 } |
| 354 | 353 |
| 355 | 354 |
| 356 void ToBooleanStub::Types::TraceTransition(Types to) const { | 355 void ToBooleanStub::Types::TraceTransition(Types to) const { |
| 357 if (!FLAG_trace_ic) return; | 356 if (!FLAG_trace_ic) return; |
| 358 char buffer[100]; | 357 char buffer[100]; |
| 359 NoAllocationStringAllocator allocator(buffer, | 358 NoAllocationStringAllocator allocator(buffer, |
| 360 static_cast<unsigned>(sizeof(buffer))); | 359 static_cast<unsigned>(sizeof(buffer))); |
| 361 StringStream stream(&allocator); | 360 StringStream stream(&allocator); |
| 362 stream.Add("[ToBooleanIC ("); | 361 stream.Add("[ToBooleanIC ("); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 382 Add(SMI); | 381 Add(SMI); |
| 383 return Smi::cast(*object)->value() != 0; | 382 return Smi::cast(*object)->value() != 0; |
| 384 } else if (object->IsSpecObject()) { | 383 } else if (object->IsSpecObject()) { |
| 385 Add(SPEC_OBJECT); | 384 Add(SPEC_OBJECT); |
| 386 return !object->IsUndetectableObject(); | 385 return !object->IsUndetectableObject(); |
| 387 } else if (object->IsString()) { | 386 } else if (object->IsString()) { |
| 388 Add(STRING); | 387 Add(STRING); |
| 389 return !object->IsUndetectableObject() && | 388 return !object->IsUndetectableObject() && |
| 390 String::cast(*object)->length() != 0; | 389 String::cast(*object)->length() != 0; |
| 391 } else if (object->IsHeapNumber()) { | 390 } else if (object->IsHeapNumber()) { |
| 391 ASSERT(!object->IsUndetectableObject()); |
| 392 Add(HEAP_NUMBER); | 392 Add(HEAP_NUMBER); |
| 393 double value = HeapNumber::cast(*object)->value(); | 393 double value = HeapNumber::cast(*object)->value(); |
| 394 return !object->IsUndetectableObject() && value != 0 && !isnan(value); | 394 return value != 0 && !isnan(value); |
| 395 } else { | 395 } else { |
| 396 Add(INTERNAL_OBJECT); | 396 // We should never see an internal object at runtime here! |
| 397 return !object->IsUndetectableObject(); | 397 UNREACHABLE(); |
| 398 return true; |
| 398 } | 399 } |
| 399 } | 400 } |
| 400 | 401 |
| 401 | 402 |
| 402 bool ToBooleanStub::Types::NeedsMap() const { | 403 bool ToBooleanStub::Types::NeedsMap() const { |
| 403 return Contains(ToBooleanStub::SPEC_OBJECT) | 404 return Contains(ToBooleanStub::SPEC_OBJECT) |
| 404 || Contains(ToBooleanStub::STRING) | 405 || Contains(ToBooleanStub::STRING) |
| 405 || Contains(ToBooleanStub::HEAP_NUMBER) | 406 || Contains(ToBooleanStub::HEAP_NUMBER); |
| 406 || Contains(ToBooleanStub::INTERNAL_OBJECT); | 407 } |
| 408 |
| 409 |
| 410 bool ToBooleanStub::Types::CanBeUndetectable() const { |
| 411 return Contains(ToBooleanStub::SPEC_OBJECT) |
| 412 || Contains(ToBooleanStub::STRING); |
| 407 } | 413 } |
| 408 | 414 |
| 409 | 415 |
| 410 } } // namespace v8::internal | 416 } } // namespace v8::internal |
| OLD | NEW |