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

Side by Side Diff: src/hydrogen-types.cc

Issue 1405363003: Move Hydrogen and Lithium to src/crankshaft/ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased Created 5 years, 2 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
« no previous file with comments | « src/hydrogen-types.h ('k') | src/hydrogen-uint32-analysis.h » ('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 "src/hydrogen-types.h"
6
7 #include "src/ostreams.h"
8 #include "src/types-inl.h"
9
10
11 namespace v8 {
12 namespace internal {
13
14 // static
15 template <class T>
16 HType HType::FromType(typename T::TypeHandle type) {
17 if (T::Any()->Is(type)) return HType::Any();
18 if (!type->IsInhabited()) return HType::None();
19 if (type->Is(T::SignedSmall())) return HType::Smi();
20 if (type->Is(T::Number())) return HType::TaggedNumber();
21 if (type->Is(T::Null())) return HType::Null();
22 if (type->Is(T::String())) return HType::String();
23 if (type->Is(T::Boolean())) return HType::Boolean();
24 if (type->Is(T::Undefined())) return HType::Undefined();
25 if (type->Is(T::Object())) return HType::JSObject();
26 if (type->Is(T::Receiver())) return HType::JSReceiver();
27 return HType::Tagged();
28 }
29
30
31 // static
32 template
33 HType HType::FromType<Type>(Type* type);
34
35
36 // static
37 template
38 HType HType::FromType<HeapType>(Handle<HeapType> type);
39
40
41 // static
42 HType HType::FromValue(Handle<Object> value) {
43 if (value->IsSmi()) return HType::Smi();
44 if (value->IsNull()) return HType::Null();
45 if (value->IsHeapNumber()) {
46 double n = Handle<v8::internal::HeapNumber>::cast(value)->value();
47 return IsSmiDouble(n) ? HType::Smi() : HType::HeapNumber();
48 }
49 if (value->IsString()) return HType::String();
50 if (value->IsBoolean()) return HType::Boolean();
51 if (value->IsUndefined()) return HType::Undefined();
52 if (value->IsJSArray()) return HType::JSArray();
53 if (value->IsJSObject()) return HType::JSObject();
54 DCHECK(value->IsHeapObject());
55 return HType::HeapObject();
56 }
57
58
59 std::ostream& operator<<(std::ostream& os, const HType& t) {
60 // Note: The c1visualizer syntax for locals allows only a sequence of the
61 // following characters: A-Za-z0-9_-|:
62 switch (t.kind_) {
63 #define DEFINE_CASE(Name, mask) \
64 case HType::k##Name: \
65 return os << #Name;
66 HTYPE_LIST(DEFINE_CASE)
67 #undef DEFINE_CASE
68 }
69 UNREACHABLE();
70 return os;
71 }
72
73 } // namespace internal
74 } // namespace v8
OLDNEW
« no previous file with comments | « src/hydrogen-types.h ('k') | src/hydrogen-uint32-analysis.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698