Revision: 20405
Author: [email protected]
Date: Tue Apr 1 13:11:12 2014 UTC
Log: Provide Type::Contains methods.
Also, rename all *Currently methods to Now*.
[email protected]
BUG=
Review URL: https://codereview.chromium.org/219523003
http://code.google.com/p/v8/source/detail?r=20405
Modified:
/branches/bleeding_edge/src/ic.cc
/branches/bleeding_edge/src/types-inl.h
/branches/bleeding_edge/src/types.cc
/branches/bleeding_edge/src/types.h
/branches/bleeding_edge/src/typing.cc
=======================================
--- /branches/bleeding_edge/src/ic.cc Fri Mar 28 09:49:27 2014 UTC
+++ /branches/bleeding_edge/src/ic.cc Tue Apr 1 13:11:12 2014 UTC
@@ -634,7 +634,7 @@
if (current_type->IsClass() &&
current_type->AsClass()->is_deprecated()) {
// Filter out deprecated maps to ensure their instances get migrated.
++deprecated_types;
- } else if (type->IsCurrently(current_type)) {
+ } else if (type->NowIs(current_type)) {
// If the receiver type is already in the polymorphic IC, this
indicates
// there was a prototoype chain failure. In that case, just
overwrite the
// handler.
@@ -658,7 +658,7 @@
number_of_valid_types++;
if (handler_to_overwrite >= 0) {
handlers.Set(handler_to_overwrite, code);
- if (!type->IsCurrently(types.at(handler_to_overwrite))) {
+ if (!type->NowIs(types.at(handler_to_overwrite))) {
types.Set(handler_to_overwrite, type);
}
} else {
@@ -676,7 +676,7 @@
Handle<HeapType> IC::CurrentTypeOf(Handle<Object> object, Isolate*
isolate) {
return object->IsJSGlobalObject()
? HeapType::Constant(Handle<JSGlobalObject>::cast(object), isolate)
- : HeapType::OfCurrently(object, isolate);
+ : HeapType::NowOf(object, isolate);
}
=======================================
--- /branches/bleeding_edge/src/types-inl.h Tue Apr 1 11:07:09 2014 UTC
+++ /branches/bleeding_edge/src/types-inl.h Tue Apr 1 13:11:12 2014 UTC
@@ -5,9 +5,10 @@
#ifndef V8_TYPES_INL_H_
#define V8_TYPES_INL_H_
+#include "types.h"
+
#include "factory.h"
#include "handles-inl.h"
-#include "types.h"
namespace v8 {
namespace internal {
@@ -233,6 +234,7 @@
return static_cast<int>(tagged_get<intptr_t>(as_tagged(type), 0));
}
+//
--------------------------------------------------------------------------
//
// static
i::Handle<HeapTypeConfig::Type> HeapTypeConfig::handle(Type* type) {
=======================================
--- /branches/bleeding_edge/src/types.cc Tue Apr 1 11:30:31 2014 UTC
+++ /branches/bleeding_edge/src/types.cc Tue Apr 1 13:11:12 2014 UTC
@@ -248,7 +248,7 @@
// Most precise _current_ type of a value (usually its class).
template<class Config>
-typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::OfCurrently(
+typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::NowOf(
i::Handle<i::Object> value, Region* region) {
if (value->IsSmi() ||
i::HeapObject::cast(*value)->map()->instance_type() ==
HEAP_NUMBER_TYPE ||
@@ -303,7 +303,7 @@
template<class Config>
-bool TypeImpl<Config>::IsCurrently(TypeImpl* that) {
+bool TypeImpl<Config>::NowIs(TypeImpl* that) {
return this->Is(that) ||
(this->IsConstant() && that->IsClass() &&
this->AsConstant()->IsHeapObject() &&
@@ -352,6 +352,23 @@
return false;
}
+
+
+template<class Config>
+bool TypeImpl<Config>::Contains(i::Object* value) {
+ if (this->IsConstant()) {
+ return *this->AsConstant() == value;
+ }
+ return Config::from_bitset(LubBitset(value))->Is(this);
+}
+
+
+template<class Config>
+bool TypeImpl<Config>::NowContains(i::Object* value) {
+ return this->Contains(value) ||
+ (this->IsClass() && value->IsHeapObject() &&
+ *this->AsClass() == i::HeapObject::cast(value)->map());
+}
template<class Config>
=======================================
--- /branches/bleeding_edge/src/types.h Tue Apr 1 11:07:09 2014 UTC
+++ /branches/bleeding_edge/src/types.h Tue Apr 1 13:11:12 2014 UTC
@@ -220,16 +220,23 @@
bool Is(TypeImpl* that) { return this == that || this->SlowIs(that); }
template<class TypeHandle>
bool Is(TypeHandle that) { return this->Is(*that); }
+
bool Maybe(TypeImpl* that);
template<class TypeHandle>
bool Maybe(TypeHandle that) { return this->Maybe(*that); }
+
+ // Equivalent to Constant(value)->Is(this), but avoiding allocation.
+ bool Contains(i::Object* val);
+ bool Contains(i::Handle<i::Object> val) { return this->Contains(*val); }
// State-dependent versions of Of and Is that consider subtyping between
// a constant and its map class.
- static TypeHandle OfCurrently(i::Handle<i::Object> value, Region*
region);
- bool IsCurrently(TypeImpl* that);
+ static TypeHandle NowOf(i::Handle<i::Object> value, Region* region);
+ bool NowIs(TypeImpl* that);
template<class TypeHandle>
- bool IsCurrently(TypeHandle that) { return this->IsCurrently(*that); }
+ bool NowIs(TypeHandle that) { return this->NowIs(*that); }
+ bool NowContains(i::Object* val);
+ bool NowContains(i::Handle<i::Object> val) { return
this->NowContains(*val); }
bool IsClass() { return Config::is_class(this); }
bool IsConstant() { return Config::is_constant(this); }
@@ -359,10 +366,8 @@
static inline Tagged* tagged_create(Tag tag, int size, Zone* zone);
static inline void tagged_shrink(Tagged* tagged, int size);
static inline Tag tagged_tag(Tagged* tagged);
- template<class T>
- static inline T tagged_get(Tagged* tagged, int i);
- template<class T>
- static inline void tagged_set(Tagged* tagged, int i, T value);
+ template<class T> static inline T tagged_get(Tagged* tagged, int i);
+ template<class T> static inline void tagged_set(Tagged* tagged, int i, T
val);
static inline int tagged_length(Tagged* tagged);
public:
@@ -402,6 +407,8 @@
static inline int lub_bitset(Type* type);
};
+typedef TypeImpl<ZoneTypeConfig> Type;
+
// Heap-allocated types are either smis for bitsets, maps for classes,
boxes for
// constants, or fixed arrays for unions.
@@ -437,7 +444,6 @@
static inline int lub_bitset(Type* type);
};
-typedef TypeImpl<ZoneTypeConfig> Type;
typedef TypeImpl<HeapTypeConfig> HeapType;
=======================================
--- /branches/bleeding_edge/src/typing.cc Tue Mar 18 11:50:18 2014 UTC
+++ /branches/bleeding_edge/src/typing.cc Tue Apr 1 13:11:12 2014 UTC
@@ -83,7 +83,7 @@
Effect AstTyper::ObservedOnStack(Object* value) {
- Type* lower = Type::OfCurrently(handle(value, isolate()), zone());
+ Type* lower = Type::NowOf(handle(value, isolate()), zone());
return Effect(Bounds(lower, Type::Any(zone())));
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.