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

Unified Diff: src/code-stubs.cc

Issue 7473028: Implement a type recording ToBoolean IC. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stubs.h ('k') | src/debug.cc » ('j') | src/ia32/code-stubs-ia32.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/code-stubs.h ('k') | src/debug.cc » ('j') | src/ia32/code-stubs-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698