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

Unified Diff: src/hydrogen-instructions.cc

Issue 700963002: Replace C++ bitfields with our own BitFields (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fixed AST node field sizes; more scanner fixes; undid hydrogen.h/cc changes Created 6 years, 1 month 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-instructions.h ('k') | src/profile-generator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index 188119d66bf9e08254098d9f0b89cb4881dac118..ce76fbecac93a909854dfe53c8604e52a170f06e 100644
--- a/src/hydrogen-instructions.cc
+++ b/src/hydrogen-instructions.cc
@@ -1789,7 +1789,7 @@ Range* HChange::InferRange(Zone* zone) {
Range* HConstant::InferRange(Zone* zone) {
- if (has_int32_value_) {
+ if (HasInteger32Value()) {
Range* result = new(zone) Range(int32_value_, int32_value_);
result->set_can_be_minus_zero(false);
return result;
@@ -2606,7 +2606,7 @@ std::ostream& HSimulate::PrintDataTo(std::ostream& os) const { // NOLINT
void HSimulate::ReplayEnvironment(HEnvironment* env) {
- if (done_with_replay_) return;
+ if (is_done_with_replay()) return;
DCHECK(env != NULL);
env->set_ast_id(ast_id());
env->Drop(pop_count());
@@ -2618,7 +2618,7 @@ void HSimulate::ReplayEnvironment(HEnvironment* env) {
env->Push(value);
}
}
- done_with_replay_ = true;
+ set_done_with_replay();
}
@@ -2674,36 +2674,41 @@ static bool IsInteger32(double value) {
HConstant::HConstant(Handle<Object> object, Representation r)
- : HTemplateInstruction<0>(HType::FromValue(object)),
- object_(Unique<Object>::CreateUninitialized(object)),
- object_map_(Handle<Map>::null()),
- has_stable_map_value_(false),
- has_smi_value_(false),
- has_int32_value_(false),
- has_double_value_(false),
- has_external_reference_value_(false),
- is_not_in_new_space_(true),
- boolean_value_(object->BooleanValue()),
- is_undetectable_(false),
- instance_type_(kUnknownInstanceType) {
+ : HTemplateInstruction<0>(HType::FromValue(object)),
+ object_(Unique<Object>::CreateUninitialized(object)),
+ object_map_(Handle<Map>::null()),
+ bit_field_(HasStableMapValueField::encode(false) |
+ HasSmiValueField::encode(false) |
+ HasInt32ValueField::encode(false) |
+ HasDoubleValueField::encode(false) |
+ HasExternalReferenceValueField::encode(false) |
+ IsNotInNewSpaceField::encode(true) |
+ BooleanValueField::encode(object->BooleanValue()) |
+ IsUndetectableField::encode(false) |
+ InstanceTypeField::encode(kUnknownInstanceType)) {
if (object->IsHeapObject()) {
Handle<HeapObject> heap_object = Handle<HeapObject>::cast(object);
Isolate* isolate = heap_object->GetIsolate();
Handle<Map> map(heap_object->map(), isolate);
- is_not_in_new_space_ = !isolate->heap()->InNewSpace(*object);
- instance_type_ = map->instance_type();
- is_undetectable_ = map->is_undetectable();
+ bit_field_ = IsNotInNewSpaceField::update(
+ bit_field_, !isolate->heap()->InNewSpace(*object));
+ bit_field_ = InstanceTypeField::update(bit_field_, map->instance_type());
+ bit_field_ =
+ IsUndetectableField::update(bit_field_, map->is_undetectable());
if (map->is_stable()) object_map_ = Unique<Map>::CreateImmovable(map);
- has_stable_map_value_ = (instance_type_ == MAP_TYPE &&
- Handle<Map>::cast(heap_object)->is_stable());
+ bit_field_ = HasStableMapValueField::update(
+ bit_field_,
+ HasMapValue() && Handle<Map>::cast(heap_object)->is_stable());
}
if (object->IsNumber()) {
double n = object->Number();
- has_int32_value_ = IsInteger32(n);
+ bool has_int32_value = IsInteger32(n);
+ bit_field_ = HasInt32ValueField::update(bit_field_, has_int32_value);
int32_value_ = DoubleToInt32(n);
- has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
+ bit_field_ = HasSmiValueField::update(
+ bit_field_, has_int32_value && Smi::IsValid(int32_value_));
double_value_ = n;
- has_double_value_ = true;
+ bit_field_ = HasDoubleValueField::update(bit_field_, true);
// TODO(titzer): if this heap number is new space, tenure a new one.
}
@@ -2711,112 +2716,104 @@ HConstant::HConstant(Handle<Object> object, Representation r)
}
-HConstant::HConstant(Unique<Object> object,
- Unique<Map> object_map,
- bool has_stable_map_value,
- Representation r,
- HType type,
- bool is_not_in_new_space,
- bool boolean_value,
- bool is_undetectable,
- InstanceType instance_type)
- : HTemplateInstruction<0>(type),
- object_(object),
- object_map_(object_map),
- has_stable_map_value_(has_stable_map_value),
- has_smi_value_(false),
- has_int32_value_(false),
- has_double_value_(false),
- has_external_reference_value_(false),
- is_not_in_new_space_(is_not_in_new_space),
- boolean_value_(boolean_value),
- is_undetectable_(is_undetectable),
- instance_type_(instance_type) {
+HConstant::HConstant(Unique<Object> object, Unique<Map> object_map,
+ bool has_stable_map_value, Representation r, HType type,
+ bool is_not_in_new_space, bool boolean_value,
+ bool is_undetectable, InstanceType instance_type)
+ : HTemplateInstruction<0>(type),
+ object_(object),
+ object_map_(object_map),
+ bit_field_(HasStableMapValueField::encode(has_stable_map_value) |
+ HasSmiValueField::encode(false) |
+ HasInt32ValueField::encode(false) |
+ HasDoubleValueField::encode(false) |
+ HasExternalReferenceValueField::encode(false) |
+ IsNotInNewSpaceField::encode(is_not_in_new_space) |
+ BooleanValueField::encode(boolean_value) |
+ IsUndetectableField::encode(is_undetectable) |
+ InstanceTypeField::encode(instance_type)) {
DCHECK(!object.handle().is_null());
DCHECK(!type.IsTaggedNumber() || type.IsNone());
Initialize(r);
}
-HConstant::HConstant(int32_t integer_value,
- Representation r,
- bool is_not_in_new_space,
- Unique<Object> object)
- : object_(object),
- object_map_(Handle<Map>::null()),
- has_stable_map_value_(false),
- has_smi_value_(Smi::IsValid(integer_value)),
- has_int32_value_(true),
- has_double_value_(true),
- has_external_reference_value_(false),
- is_not_in_new_space_(is_not_in_new_space),
- boolean_value_(integer_value != 0),
- is_undetectable_(false),
- int32_value_(integer_value),
- double_value_(FastI2D(integer_value)),
- instance_type_(kUnknownInstanceType) {
+HConstant::HConstant(int32_t integer_value, Representation r,
+ bool is_not_in_new_space, Unique<Object> object)
+ : object_(object),
+ object_map_(Handle<Map>::null()),
+ bit_field_(HasStableMapValueField::encode(false) |
+ HasSmiValueField::encode(Smi::IsValid(integer_value)) |
+ HasInt32ValueField::encode(true) |
+ HasDoubleValueField::encode(true) |
+ HasExternalReferenceValueField::encode(false) |
+ IsNotInNewSpaceField::encode(is_not_in_new_space) |
+ BooleanValueField::encode(integer_value != 0) |
+ IsUndetectableField::encode(false) |
+ InstanceTypeField::encode(kUnknownInstanceType)),
+ int32_value_(integer_value),
+ double_value_(FastI2D(integer_value)) {
// It's possible to create a constant with a value in Smi-range but stored
// in a (pre-existing) HeapNumber. See crbug.com/349878.
bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
- bool is_smi = has_smi_value_ && !could_be_heapobject;
+ bool is_smi = HasSmiValue() && !could_be_heapobject;
set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
Initialize(r);
}
-HConstant::HConstant(double double_value,
- Representation r,
- bool is_not_in_new_space,
- Unique<Object> object)
- : object_(object),
- object_map_(Handle<Map>::null()),
- has_stable_map_value_(false),
- has_int32_value_(IsInteger32(double_value)),
- has_double_value_(true),
- has_external_reference_value_(false),
- is_not_in_new_space_(is_not_in_new_space),
- boolean_value_(double_value != 0 && !std::isnan(double_value)),
- is_undetectable_(false),
- int32_value_(DoubleToInt32(double_value)),
- double_value_(double_value),
- instance_type_(kUnknownInstanceType) {
- has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
+HConstant::HConstant(double double_value, Representation r,
+ bool is_not_in_new_space, Unique<Object> object)
+ : object_(object),
+ object_map_(Handle<Map>::null()),
+ bit_field_(HasStableMapValueField::encode(false) |
+ HasInt32ValueField::encode(IsInteger32(double_value)) |
+ HasDoubleValueField::encode(true) |
+ HasExternalReferenceValueField::encode(false) |
+ IsNotInNewSpaceField::encode(is_not_in_new_space) |
+ BooleanValueField::encode(double_value != 0 &&
+ !std::isnan(double_value)) |
+ IsUndetectableField::encode(false) |
+ InstanceTypeField::encode(kUnknownInstanceType)),
+ int32_value_(DoubleToInt32(double_value)),
+ double_value_(double_value) {
+ bit_field_ = HasSmiValueField::update(
+ bit_field_, HasInteger32Value() && Smi::IsValid(int32_value_));
// It's possible to create a constant with a value in Smi-range but stored
// in a (pre-existing) HeapNumber. See crbug.com/349878.
bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
- bool is_smi = has_smi_value_ && !could_be_heapobject;
+ bool is_smi = HasSmiValue() && !could_be_heapobject;
set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
Initialize(r);
}
HConstant::HConstant(ExternalReference reference)
- : HTemplateInstruction<0>(HType::Any()),
- object_(Unique<Object>(Handle<Object>::null())),
- object_map_(Handle<Map>::null()),
- has_stable_map_value_(false),
- has_smi_value_(false),
- has_int32_value_(false),
- has_double_value_(false),
- has_external_reference_value_(true),
- is_not_in_new_space_(true),
- boolean_value_(true),
- is_undetectable_(false),
- external_reference_value_(reference),
- instance_type_(kUnknownInstanceType) {
+ : HTemplateInstruction<0>(HType::Any()),
+ object_(Unique<Object>(Handle<Object>::null())),
+ object_map_(Handle<Map>::null()),
+ bit_field_(
+ HasStableMapValueField::encode(false) |
+ HasSmiValueField::encode(false) | HasInt32ValueField::encode(false) |
+ HasDoubleValueField::encode(false) |
+ HasExternalReferenceValueField::encode(true) |
+ IsNotInNewSpaceField::encode(true) | BooleanValueField::encode(true) |
+ IsUndetectableField::encode(false) |
+ InstanceTypeField::encode(kUnknownInstanceType)),
+ external_reference_value_(reference) {
Initialize(Representation::External());
}
void HConstant::Initialize(Representation r) {
if (r.IsNone()) {
- if (has_smi_value_ && SmiValuesAre31Bits()) {
+ if (HasSmiValue() && SmiValuesAre31Bits()) {
r = Representation::Smi();
- } else if (has_int32_value_) {
+ } else if (HasInteger32Value()) {
r = Representation::Integer32();
- } else if (has_double_value_) {
+ } else if (HasDoubleValue()) {
r = Representation::Double();
- } else if (has_external_reference_value_) {
+ } else if (HasExternalReferenceValue()) {
r = Representation::External();
} else {
Handle<Object> object = object_.handle();
@@ -2843,16 +2840,16 @@ void HConstant::Initialize(Representation r) {
bool HConstant::ImmortalImmovable() const {
- if (has_int32_value_) {
+ if (HasInteger32Value()) {
return false;
}
- if (has_double_value_) {
+ if (HasDoubleValue()) {
if (IsSpecialDouble()) {
return true;
}
return false;
}
- if (has_external_reference_value_) {
+ if (HasExternalReferenceValue()) {
return false;
}
@@ -2893,44 +2890,35 @@ bool HConstant::EmitAtUses() {
HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const {
- if (r.IsSmi() && !has_smi_value_) return NULL;
- if (r.IsInteger32() && !has_int32_value_) return NULL;
- if (r.IsDouble() && !has_double_value_) return NULL;
- if (r.IsExternal() && !has_external_reference_value_) return NULL;
- if (has_int32_value_) {
- return new(zone) HConstant(int32_value_, r, is_not_in_new_space_, object_);
+ if (r.IsSmi() && !HasSmiValue()) return NULL;
+ if (r.IsInteger32() && !HasInteger32Value()) return NULL;
+ if (r.IsDouble() && !HasDoubleValue()) return NULL;
+ if (r.IsExternal() && !HasExternalReferenceValue()) return NULL;
+ if (HasInteger32Value()) {
+ return new (zone) HConstant(int32_value_, r, NotInNewSpace(), object_);
}
- if (has_double_value_) {
- return new(zone) HConstant(double_value_, r, is_not_in_new_space_, object_);
+ if (HasDoubleValue()) {
+ return new (zone) HConstant(double_value_, r, NotInNewSpace(), object_);
}
- if (has_external_reference_value_) {
+ if (HasExternalReferenceValue()) {
return new(zone) HConstant(external_reference_value_);
}
DCHECK(!object_.handle().is_null());
- return new(zone) HConstant(object_,
- object_map_,
- has_stable_map_value_,
- r,
- type_,
- is_not_in_new_space_,
- boolean_value_,
- is_undetectable_,
- instance_type_);
+ return new (zone) HConstant(object_, object_map_, HasStableMapValue(), r,
+ type_, NotInNewSpace(), BooleanValue(),
+ IsUndetectable(), GetInstanceType());
}
Maybe<HConstant*> HConstant::CopyToTruncatedInt32(Zone* zone) {
HConstant* res = NULL;
- if (has_int32_value_) {
- res = new(zone) HConstant(int32_value_,
- Representation::Integer32(),
- is_not_in_new_space_,
- object_);
- } else if (has_double_value_) {
- res = new(zone) HConstant(DoubleToInt32(double_value_),
- Representation::Integer32(),
- is_not_in_new_space_,
- object_);
+ if (HasInteger32Value()) {
+ res = new (zone) HConstant(int32_value_, Representation::Integer32(),
+ NotInNewSpace(), object_);
+ } else if (HasDoubleValue()) {
+ res = new (zone)
+ HConstant(DoubleToInt32(double_value_), Representation::Integer32(),
+ NotInNewSpace(), object_);
}
return Maybe<HConstant*>(res != NULL, res);
}
@@ -2952,11 +2940,11 @@ Maybe<HConstant*> HConstant::CopyToTruncatedNumber(Zone* zone) {
std::ostream& HConstant::PrintDataTo(std::ostream& os) const { // NOLINT
- if (has_int32_value_) {
+ if (HasInteger32Value()) {
os << int32_value_ << " ";
- } else if (has_double_value_) {
+ } else if (HasDoubleValue()) {
os << double_value_ << " ";
- } else if (has_external_reference_value_) {
+ } else if (HasExternalReferenceValue()) {
os << reinterpret_cast<void*>(external_reference_value_.address()) << " ";
} else {
// The handle() method is silently and lazily mutating the object.
@@ -2965,7 +2953,7 @@ std::ostream& HConstant::PrintDataTo(std::ostream& os) const { // NOLINT
if (HasStableMapValue()) os << "[stable-map] ";
if (HasObjectMap()) os << "[map " << *ObjectMap().handle() << "] ";
}
- if (!is_not_in_new_space_) os << "[new space] ";
+ if (!NotInNewSpace()) os << "[new space] ";
return os;
}
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698