Chromium Code Reviews| 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 case IN_LOOP: in_loop_name = "_InLoop"; break; | 322 case IN_LOOP: in_loop_name = "_InLoop"; break; |
| 323 } | 323 } |
| 324 const char* flags_name = NULL; // Make g++ happy. | 324 const char* flags_name = NULL; // Make g++ happy. |
| 325 switch (flags_) { | 325 switch (flags_) { |
| 326 case NO_CALL_FUNCTION_FLAGS: flags_name = ""; break; | 326 case NO_CALL_FUNCTION_FLAGS: flags_name = ""; break; |
| 327 case RECEIVER_MIGHT_BE_IMPLICIT: flags_name = "_Implicit"; break; | 327 case RECEIVER_MIGHT_BE_IMPLICIT: flags_name = "_Implicit"; break; |
| 328 } | 328 } |
| 329 stream->Add("CallFunctionStub_Args%d%s%s", argc_, in_loop_name, flags_name); | 329 stream->Add("CallFunctionStub_Args%d%s%s", argc_, in_loop_name, flags_name); |
| 330 } | 330 } |
| 331 | 331 |
| 332 | |
| 333 void ToBooleanStub::PrintName(StringStream* stream) { | |
| 334 stream->Add("ToBooleanStub_"); | |
| 335 types_.Print(stream); | |
| 336 } | |
| 337 | |
| 338 | |
| 339 void ToBooleanStub::Types::Print(StringStream* stream) { | |
| 340 if (IsEmpty()) stream->Add("None"); | |
| 341 if (Contains(UNDEFINED)) stream->Add("Undefined"); | |
|
danno
2011/07/21 12:39:07
Doesn't the lack of separation between types end u
Sven Panne
2011/07/21 13:49:28
This is intended and consistent with other convers
| |
| 342 if (Contains(BOOLEAN)) stream->Add("Bool"); | |
| 343 if (Contains(SMI)) stream->Add("Smi"); | |
| 344 if (Contains(NULL_TYPE)) stream->Add("Null"); | |
| 345 if (Contains(UNDETECTABLE)) stream->Add("Undetectable"); | |
| 346 if (Contains(SPEC_OBJECT)) stream->Add("SpecObject"); | |
| 347 if (Contains(STRING)) stream->Add("String"); | |
| 348 if (Contains(HEAP_NUMBER)) stream->Add("HeapNumber"); | |
| 349 if (Contains(INTERNAL_OBJECT)) stream->Add("InternalObject"); | |
| 350 } | |
| 351 | |
| 352 | |
| 353 void ToBooleanStub::Types::TraceTransition(Types to) { | |
| 354 if (!FLAG_trace_ic) return; | |
| 355 char buffer[100]; | |
| 356 NoAllocationStringAllocator allocator(buffer, | |
| 357 static_cast<unsigned>(sizeof(buffer))); | |
| 358 StringStream stream(&allocator); | |
| 359 stream.Add("[ToBooleanIC ("); | |
| 360 Print(&stream); | |
| 361 stream.Add("->"); | |
| 362 to.Print(&stream); | |
| 363 stream.Add(")]\n"); | |
| 364 stream.OutputToStdOut(); | |
| 365 } | |
| 366 | |
| 367 | |
| 368 bool ToBooleanStub::Types::Record(Handle<Object> object) { | |
| 369 if (object->IsUndefined()) { | |
| 370 Add(UNDEFINED); | |
| 371 return false; | |
| 372 } else if (object->IsBoolean()) { | |
| 373 Add(BOOLEAN); | |
| 374 return object->IsTrue(); | |
| 375 } else if (object->IsNull()) { | |
| 376 Add(NULL_TYPE); | |
| 377 return false; | |
| 378 } else if (object->IsSmi()) { | |
| 379 Add(SMI); | |
| 380 return Smi::cast(*object)->value() != 0; | |
| 381 } else if (object->IsUndetectableObject()) { | |
| 382 Add(UNDETECTABLE); | |
| 383 return false; | |
| 384 } else if (object->IsSpecObject()) { | |
| 385 Add(SPEC_OBJECT); | |
| 386 return true; | |
| 387 } else if (object->IsString()) { | |
| 388 Add(STRING); | |
| 389 return String::cast(*object)->length() != 0; | |
| 390 } else if (object->IsHeapNumber()) { | |
| 391 Add(HEAP_NUMBER); | |
| 392 double value = HeapNumber::cast(*object)->value(); | |
| 393 return value != 0 && !isnan(value); | |
| 394 } else { | |
| 395 Add(INTERNAL_OBJECT); | |
| 396 return true; | |
| 397 } | |
| 398 } | |
| 399 | |
| 400 | |
| 332 } } // namespace v8::internal | 401 } } // namespace v8::internal |
| OLD | NEW |