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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen-types.h ('k') | src/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "hydrogen-types.h"
6
7 #include "types-inl.h"
8
9
10 namespace v8 {
11 namespace internal {
12
13 // static
14 template <class T>
15 HType HType::FromType(typename T::TypeHandle type) {
16 if (T::Any()->Is(type)) return HType::Any();
17 if (type->Is(T::None())) return HType::None();
18 if (type->Is(T::SignedSmall())) return HType::Smi();
19 if (type->Is(T::Number())) return HType::TaggedNumber();
20 if (type->Is(T::Null())) return HType::Null();
21 if (type->Is(T::String())) return HType::String();
22 if (type->Is(T::Boolean())) return HType::Boolean();
23 if (type->Is(T::Undefined())) return HType::Undefined();
24 if (type->Is(T::Array())) return HType::JSArray();
25 if (type->Is(T::Object())) return HType::JSObject();
26 return HType::Tagged();
27 }
28
29
30 // static
31 template
32 HType HType::FromType<Type>(Type* type);
33
34
35 // static
36 template
37 HType HType::FromType<HeapType>(Handle<HeapType> type);
38
39
40 // static
41 HType HType::FromValue(Handle<Object> value) {
42 if (value->IsSmi()) return HType::Smi();
43 if (value->IsNull()) return HType::Null();
44 if (value->IsHeapNumber()) return HType::HeapNumber();
45 if (value->IsString()) return HType::String();
46 if (value->IsBoolean()) return HType::Boolean();
47 if (value->IsUndefined()) return HType::Undefined();
48 if (value->IsJSArray()) return HType::JSArray();
49 if (value->IsJSObject()) return HType::JSObject();
50 ASSERT(value->IsHeapObject());
51 return HType::HeapObject();
52 }
53
54
55 const char* HType::ToString() const {
56 // Note: The c1visualizer syntax for locals allows only a sequence of the
57 // following characters: A-Za-z0-9_-|:
58 switch (kind_) {
59 #define DEFINE_CASE(Name, mask) case k##Name: return #Name;
60 HTYPE_LIST(DEFINE_CASE)
61 #undef DEFINE_CASE
62 }
63 UNREACHABLE();
64 return NULL;
65 }
66
67 } } // namespace v8::internal
OLDNEW
« 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