2014-05-29 04:13:50 +00:00
|
|
|
// 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.
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/hydrogen-types.h"
|
2014-05-29 04:13:50 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/types-inl.h"
|
2014-05-29 04:13:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-07 09:57:29 +00:00
|
|
|
OStream& operator<<(OStream& os, const HType& t) {
|
2014-05-29 04:13:50 +00:00
|
|
|
// Note: The c1visualizer syntax for locals allows only a sequence of the
|
|
|
|
// following characters: A-Za-z0-9_-|:
|
2014-07-07 09:57:29 +00:00
|
|
|
switch (t.kind_) {
|
|
|
|
#define DEFINE_CASE(Name, mask) \
|
|
|
|
case HType::k##Name: \
|
|
|
|
return os << #Name;
|
2014-05-29 04:13:50 +00:00
|
|
|
HTYPE_LIST(DEFINE_CASE)
|
2014-07-07 09:57:29 +00:00
|
|
|
#undef DEFINE_CASE
|
2014-05-29 04:13:50 +00:00
|
|
|
}
|
|
|
|
UNREACHABLE();
|
2014-07-07 09:57:29 +00:00
|
|
|
return os;
|
2014-05-29 04:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|