Index: src/code-stubs.cc |
=================================================================== |
--- src/code-stubs.cc (revision 8701) |
+++ src/code-stubs.cc (working copy) |
@@ -329,4 +329,73 @@ |
stream->Add("CallFunctionStub_Args%d%s%s", argc_, in_loop_name, flags_name); |
} |
+ |
+void ToBooleanStub::PrintName(StringStream* stream) { |
+ stream->Add("ToBooleanStub_"); |
+ types_.Print(stream); |
+} |
+ |
+ |
+void ToBooleanStub::Types::Print(StringStream* stream) { |
+ if (IsEmpty()) stream->Add("None"); |
+ 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
|
+ if (Contains(BOOLEAN)) stream->Add("Bool"); |
+ if (Contains(SMI)) stream->Add("Smi"); |
+ if (Contains(NULL_TYPE)) stream->Add("Null"); |
+ if (Contains(UNDETECTABLE)) stream->Add("Undetectable"); |
+ if (Contains(SPEC_OBJECT)) stream->Add("SpecObject"); |
+ if (Contains(STRING)) stream->Add("String"); |
+ if (Contains(HEAP_NUMBER)) stream->Add("HeapNumber"); |
+ if (Contains(INTERNAL_OBJECT)) stream->Add("InternalObject"); |
+} |
+ |
+ |
+void ToBooleanStub::Types::TraceTransition(Types to) { |
+ if (!FLAG_trace_ic) return; |
+ char buffer[100]; |
+ NoAllocationStringAllocator allocator(buffer, |
+ static_cast<unsigned>(sizeof(buffer))); |
+ StringStream stream(&allocator); |
+ stream.Add("[ToBooleanIC ("); |
+ Print(&stream); |
+ stream.Add("->"); |
+ to.Print(&stream); |
+ stream.Add(")]\n"); |
+ stream.OutputToStdOut(); |
+} |
+ |
+ |
+bool ToBooleanStub::Types::Record(Handle<Object> object) { |
+ if (object->IsUndefined()) { |
+ Add(UNDEFINED); |
+ return false; |
+ } else if (object->IsBoolean()) { |
+ Add(BOOLEAN); |
+ return object->IsTrue(); |
+ } else if (object->IsNull()) { |
+ Add(NULL_TYPE); |
+ return false; |
+ } else if (object->IsSmi()) { |
+ Add(SMI); |
+ return Smi::cast(*object)->value() != 0; |
+ } else if (object->IsUndetectableObject()) { |
+ Add(UNDETECTABLE); |
+ return false; |
+ } else if (object->IsSpecObject()) { |
+ Add(SPEC_OBJECT); |
+ return true; |
+ } else if (object->IsString()) { |
+ Add(STRING); |
+ return String::cast(*object)->length() != 0; |
+ } else if (object->IsHeapNumber()) { |
+ Add(HEAP_NUMBER); |
+ double value = HeapNumber::cast(*object)->value(); |
+ return value != 0 && !isnan(value); |
+ } else { |
+ Add(INTERNAL_OBJECT); |
+ return true; |
+ } |
+} |
+ |
+ |
} } // namespace v8::internal |