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

Unified Diff: src/hydrogen-types.cc

Issue 300893003: Refactor HType to get rid of various hacks. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix compilation. Created 6 years, 7 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/hydrogen-types.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-types.cc
diff --git a/src/hydrogen-types.cc b/src/hydrogen-types.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2d83e1bf2a5290a452f53d81e8ab530c9a584379
--- /dev/null
+++ b/src/hydrogen-types.cc
@@ -0,0 +1,67 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "hydrogen-types.h"
+
+#include "types-inl.h"
+
+
+namespace v8 {
+namespace internal {
+
+// static
+template <class T>
+HType HType::FromType(typename T::TypeHandle type) {
+ if (T::Any()->Is(type)) return HType::Any();
+ if (type->Is(T::None())) return HType::None();
+ if (type->Is(T::SignedSmall())) return HType::Smi();
+ if (type->Is(T::Number())) return HType::TaggedNumber();
+ if (type->Is(T::Null())) return HType::Null();
+ if (type->Is(T::String())) return HType::String();
+ if (type->Is(T::Boolean())) return HType::Boolean();
+ if (type->Is(T::Undefined())) return HType::Undefined();
+ if (type->Is(T::Array())) return HType::JSArray();
+ if (type->Is(T::Object())) return HType::JSObject();
+ return HType::Tagged();
+}
+
+
+// static
+template
+HType HType::FromType<Type>(Type* type);
+
+
+// static
+template
+HType HType::FromType<HeapType>(Handle<HeapType> type);
+
+
+// static
+HType HType::FromValue(Handle<Object> value) {
+ if (value->IsSmi()) return HType::Smi();
+ if (value->IsNull()) return HType::Null();
+ if (value->IsHeapNumber()) return HType::HeapNumber();
+ if (value->IsString()) return HType::String();
+ if (value->IsBoolean()) return HType::Boolean();
+ if (value->IsUndefined()) return HType::Undefined();
+ if (value->IsJSArray()) return HType::JSArray();
+ if (value->IsJSObject()) return HType::JSObject();
+ ASSERT(value->IsHeapObject());
+ return HType::HeapObject();
+}
+
+
+const char* HType::ToString() const {
+ // Note: The c1visualizer syntax for locals allows only a sequence of the
+ // following characters: A-Za-z0-9_-|:
+ switch (kind_) {
+ #define DEFINE_CASE(Name, mask) case k##Name: return #Name;
+ HTYPE_LIST(DEFINE_CASE)
+ #undef DEFINE_CASE
+ }
+ UNREACHABLE();
+ return NULL;
+}
+
+} } // namespace v8::internal
« no previous file with comments | « src/hydrogen-types.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698