Zonify types in compiler frontend

Clean up some zone/isolate handling in AST and its visitors on the way.

(Based on https://codereview.chromium.org/103743004/)

R=jkummerow@chromium.org, titzer@chromium.org
BUG=

Review URL: https://codereview.chromium.org/102563004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18719 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
rossberg@chromium.org 2014-01-21 16:22:52 +00:00
parent fb0c43f0ca
commit 0d906a8bdb
40 changed files with 639 additions and 645 deletions

View File

@ -44,8 +44,8 @@ enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
class CodeGenerator: public AstVisitor {
public:
explicit CodeGenerator(Isolate* isolate) {
InitializeAstVisitor(isolate);
explicit CodeGenerator(Zone* zone) {
InitializeAstVisitor(zone);
}
static bool MakeCode(CompilationInfo* info);

View File

@ -1160,7 +1160,7 @@ void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
#define __ ACCESS_MASM(masm())
Register StubCompiler::CheckPrototypes(Handle<Type> type,
Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Register holder_reg,
@ -1296,7 +1296,7 @@ void StoreStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
Register LoadStubCompiler::CallbackHandlerFrontend(
Handle<Type> type,
Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,
@ -1962,7 +1962,7 @@ Handle<Code> StoreStubCompiler::CompileStoreInterceptor(
}
Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<Type> type,
Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<HeapType> type,
Handle<JSObject> last,
Handle<Name> name) {
NonexistentHandlerFrontend(type, last, name);
@ -2045,7 +2045,7 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
Handle<Code> LoadStubCompiler::CompileLoadGlobal(
Handle<Type> type,
Handle<HeapType> type,
Handle<GlobalObject> global,
Handle<PropertyCell> cell,
Handle<Name> name,
@ -2101,13 +2101,13 @@ Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
int number_of_handled_maps = 0;
__ ldr(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset));
for (int current = 0; current < receiver_count; ++current) {
Handle<Type> type = types->at(current);
Handle<HeapType> type = types->at(current);
Handle<Map> map = IC::TypeToMap(*type, isolate());
if (!map->is_deprecated()) {
number_of_handled_maps++;
__ mov(ip, Operand(map));
__ cmp(map_reg, ip);
if (type->Is(Type::Number())) {
if (type->Is(HeapType::Number())) {
ASSERT(!number_case.is_unused());
__ bind(&number_case);
}

View File

@ -82,8 +82,8 @@ bool Expression::IsUndefinedLiteral(Isolate* isolate) {
}
VariableProxy::VariableProxy(Isolate* isolate, Variable* var, int position)
: Expression(isolate, position),
VariableProxy::VariableProxy(Zone* zone, Variable* var, int position)
: Expression(zone, position),
name_(var->name()),
var_(NULL), // Will be set by the call to BindTo.
is_this_(var->is_this()),
@ -94,12 +94,12 @@ VariableProxy::VariableProxy(Isolate* isolate, Variable* var, int position)
}
VariableProxy::VariableProxy(Isolate* isolate,
VariableProxy::VariableProxy(Zone* zone,
Handle<String> name,
bool is_this,
Interface* interface,
int position)
: Expression(isolate, position),
: Expression(zone, position),
name_(name),
var_(NULL),
is_this_(is_this),
@ -126,17 +126,17 @@ void VariableProxy::BindTo(Variable* var) {
}
Assignment::Assignment(Isolate* isolate,
Assignment::Assignment(Zone* zone,
Token::Value op,
Expression* target,
Expression* value,
int pos)
: Expression(isolate, pos),
: Expression(zone, pos),
op_(op),
target_(target),
value_(value),
binary_operation_(NULL),
assignment_id_(GetNextId(isolate)),
assignment_id_(GetNextId(zone)),
is_uninitialized_(false),
is_pre_monomorphic_(false),
store_mode_(STANDARD_STORE) { }
@ -203,15 +203,14 @@ void FunctionLiteral::InitializeSharedInfo(
}
ObjectLiteralProperty::ObjectLiteralProperty(Literal* key,
Expression* value,
Isolate* isolate) {
ObjectLiteralProperty::ObjectLiteralProperty(
Zone* zone, Literal* key, Expression* value) {
emit_store_ = true;
key_ = key;
value_ = value;
Object* k = *key->value();
if (k->IsInternalizedString() &&
isolate->heap()->proto_string()->Equals(String::cast(k))) {
zone->isolate()->heap()->proto_string()->Equals(String::cast(k))) {
kind_ = PROTOTYPE;
} else if (value_->AsMaterializedLiteral() != NULL) {
kind_ = MATERIALIZED_LITERAL;
@ -223,8 +222,8 @@ ObjectLiteralProperty::ObjectLiteralProperty(Literal* key,
}
ObjectLiteralProperty::ObjectLiteralProperty(bool is_getter,
FunctionLiteral* value) {
ObjectLiteralProperty::ObjectLiteralProperty(
Zone* zone, bool is_getter, FunctionLiteral* value) {
emit_store_ = true;
value_ = value;
kind_ = is_getter ? GETTER : SETTER;
@ -1146,16 +1145,16 @@ RegExpAlternative::RegExpAlternative(ZoneList<RegExpTree*>* nodes)
}
CaseClause::CaseClause(Isolate* isolate,
CaseClause::CaseClause(Zone* zone,
Expression* label,
ZoneList<Statement*>* statements,
int pos)
: Expression(isolate, pos),
: Expression(zone, pos),
label_(label),
statements_(statements),
compare_type_(Type::None(isolate)),
compare_id_(AstNode::GetNextId(isolate)),
entry_id_(AstNode::GetNextId(isolate)) {
compare_type_(Type::None(zone)),
compare_id_(AstNode::GetNextId(zone)),
entry_id_(AstNode::GetNextId(zone)) {
}

443
src/ast.h

File diff suppressed because it is too large Load Diff

View File

@ -323,7 +323,7 @@ template <>
HValue* CodeStubGraphBuilder<NumberToStringStub>::BuildCodeStub() {
info()->MarkAsSavesCallerDoubles();
HValue* number = GetParameter(NumberToStringStub::kNumber);
return BuildNumberToString(number, Type::Number(isolate()));
return BuildNumberToString(number, Type::Number(zone()));
}
@ -841,7 +841,7 @@ HValue* CodeStubGraphBuilder<CompareNilICStub>::BuildCodeInitializedStub() {
CompareNilICStub* stub = casted_stub();
HIfContinuation continuation;
Handle<Map> sentinel_map(isolate->heap()->meta_map());
Handle<Type> type = stub->GetType(isolate, sentinel_map);
Type* type = stub->GetType(zone(), sentinel_map);
BuildCompareNil(GetParameter(0), type, &continuation);
IfBuilder if_nil(this, &continuation);
if_nil.Then();
@ -868,9 +868,9 @@ HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() {
HValue* left = GetParameter(BinaryOpICStub::kLeft);
HValue* right = GetParameter(BinaryOpICStub::kRight);
Handle<Type> left_type = state.GetLeftType(isolate());
Handle<Type> right_type = state.GetRightType(isolate());
Handle<Type> result_type = state.GetResultType(isolate());
Type* left_type = state.GetLeftType(zone());
Type* right_type = state.GetRightType(zone());
Type* result_type = state.GetResultType(zone());
ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) &&
(state.HasSideEffects() || !result_type->Is(Type::None())));
@ -889,7 +889,7 @@ HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() {
{
Push(BuildBinaryOperation(
state.op(), left, right,
Type::String(isolate()), right_type,
Type::String(zone()), right_type,
result_type, state.fixed_right_arg(),
allocation_mode));
}
@ -909,7 +909,7 @@ HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() {
{
Push(BuildBinaryOperation(
state.op(), left, right,
left_type, Type::String(isolate()),
left_type, Type::String(zone()),
result_type, state.fixed_right_arg(),
allocation_mode));
}
@ -983,9 +983,9 @@ HValue* CodeStubGraphBuilder<BinaryOpWithAllocationSiteStub>::BuildCodeStub() {
HValue* left = GetParameter(BinaryOpWithAllocationSiteStub::kLeft);
HValue* right = GetParameter(BinaryOpWithAllocationSiteStub::kRight);
Handle<Type> left_type = state.GetLeftType(isolate());
Handle<Type> right_type = state.GetRightType(isolate());
Handle<Type> result_type = state.GetResultType(isolate());
Type* left_type = state.GetLeftType(zone());
Type* right_type = state.GetRightType(zone());
Type* result_type = state.GetResultType(zone());
HAllocationMode allocation_mode(allocation_site);
return BuildBinaryOperation(state.op(), left, right,

View File

@ -476,37 +476,33 @@ void CompareNilICStub::State::Print(StringStream* stream) const {
}
Handle<Type> CompareNilICStub::GetType(
Isolate* isolate,
Handle<Map> map) {
Type* CompareNilICStub::GetType(Zone* zone, Handle<Map> map) {
if (state_.Contains(CompareNilICStub::GENERIC)) {
return Type::Any(isolate);
return Type::Any(zone);
}
Handle<Type> result = Type::None(isolate);
Type* result = Type::None(zone);
if (state_.Contains(CompareNilICStub::UNDEFINED)) {
result = Type::Union(result, Type::Undefined(isolate), isolate);
result = Type::Union(result, Type::Undefined(zone), zone);
}
if (state_.Contains(CompareNilICStub::NULL_TYPE)) {
result = Type::Union(result, Type::Null(isolate), isolate);
result = Type::Union(result, Type::Null(zone), zone);
}
if (state_.Contains(CompareNilICStub::MONOMORPHIC_MAP)) {
Handle<Type> type = map.is_null()
? Type::Detectable(isolate) : Type::Class(map, isolate);
result = Type::Union(result, type, isolate);
Type* type =
map.is_null() ? Type::Detectable(zone) : Type::Class(map, zone);
result = Type::Union(result, type, zone);
}
return result;
}
Handle<Type> CompareNilICStub::GetInputType(
Isolate* isolate,
Handle<Map> map) {
Handle<Type> output_type = GetType(isolate, map);
Handle<Type> nil_type = nil_value_ == kNullValue
? Type::Null(isolate) : Type::Undefined(isolate);
return Type::Union(output_type, nil_type, isolate);
Type* CompareNilICStub::GetInputType(Zone* zone, Handle<Map> map) {
Type* output_type = GetType(zone, map);
Type* nil_type =
nil_value_ == kNullValue ? Type::Null(zone) : Type::Undefined(zone);
return Type::Union(output_type, nil_type, zone);
}

View File

@ -1368,8 +1368,8 @@ class ICCompareStub: public PlatformCodeStub {
class CompareNilICStub : public HydrogenCodeStub {
public:
Handle<Type> GetType(Isolate* isolate, Handle<Map> map = Handle<Map>());
Handle<Type> GetInputType(Isolate* isolate, Handle<Map> map);
Type* GetType(Zone* zone, Handle<Map> map = Handle<Map>());
Type* GetInputType(Zone* zone, Handle<Map> map);
explicit CompareNilICStub(NilValue nil) : nil_value_(nil) { }

View File

@ -89,12 +89,12 @@ void CodeGenerator::MakeCodePrologue(CompilationInfo* info, const char* kind) {
#ifdef DEBUG
if (!info->IsStub() && print_source) {
PrintF("--- Source from AST ---\n%s\n",
PrettyPrinter(info->isolate()).PrintProgram(info->function()));
PrettyPrinter(info->zone()).PrintProgram(info->function()));
}
if (!info->IsStub() && print_ast) {
PrintF("--- AST ---\n%s\n",
AstPrinter(info->isolate()).PrintProgram(info->function()));
AstPrinter(info->zone()).PrintProgram(info->function()));
}
#endif // DEBUG
}

View File

@ -59,24 +59,24 @@ struct Effect {
Effect(Bounds b, Modality m = DEFINITE) : modality(m), bounds(b) {}
// The unknown effect.
static Effect Unknown(Isolate* isolate) {
return Effect(Bounds::Unbounded(isolate), POSSIBLE);
static Effect Unknown(Zone* zone) {
return Effect(Bounds::Unbounded(zone), POSSIBLE);
}
static Effect Forget(Isolate* isolate) {
return Effect(Bounds::Unbounded(isolate), DEFINITE);
static Effect Forget(Zone* zone) {
return Effect(Bounds::Unbounded(zone), DEFINITE);
}
// Sequential composition, as in 'e1; e2'.
static Effect Seq(Effect e1, Effect e2, Isolate* isolate) {
static Effect Seq(Effect e1, Effect e2, Zone* zone) {
if (e2.modality == DEFINITE) return e2;
return Effect(Bounds::Either(e1.bounds, e2.bounds, isolate), e1.modality);
return Effect(Bounds::Either(e1.bounds, e2.bounds, zone), e1.modality);
}
// Alternative composition, as in 'cond ? e1 : e2'.
static Effect Alt(Effect e1, Effect e2, Isolate* isolate) {
static Effect Alt(Effect e1, Effect e2, Zone* zone) {
return Effect(
Bounds::Either(e1.bounds, e2.bounds, isolate),
Bounds::Either(e1.bounds, e2.bounds, zone),
e1.modality == POSSIBLE ? POSSIBLE : e2.modality);
}
};
@ -106,20 +106,20 @@ class EffectsMixin: public Base {
Effect Lookup(Var var) {
Locator locator;
return this->Find(var, &locator)
? locator.value() : Effect::Unknown(Base::isolate());
? locator.value() : Effect::Unknown(Base::zone());
}
Bounds LookupBounds(Var var) {
Effect effect = Lookup(var);
return effect.modality == Effect::DEFINITE
? effect.bounds : Bounds::Unbounded(Base::isolate());
? effect.bounds : Bounds::Unbounded(Base::zone());
}
// Sequential composition.
void Seq(Var var, Effect effect) {
Locator locator;
if (!this->Insert(var, &locator)) {
effect = Effect::Seq(locator.value(), effect, Base::isolate());
effect = Effect::Seq(locator.value(), effect, Base::zone());
}
locator.set_value(effect);
}
@ -133,7 +133,7 @@ class EffectsMixin: public Base {
void Alt(Var var, Effect effect) {
Locator locator;
if (!this->Insert(var, &locator)) {
effect = Effect::Alt(locator.value(), effect, Base::isolate());
effect = Effect::Alt(locator.value(), effect, Base::zone());
}
locator.set_value(effect);
}
@ -148,7 +148,7 @@ class EffectsMixin: public Base {
// Invalidation.
void Forget() {
Overrider override = {
Effect::Forget(Base::isolate()), Effects(Base::zone()) };
Effect::Forget(Base::zone()), Effects(Base::zone()) };
this->ForEach(&override);
Seq(override.effects);
}
@ -206,7 +206,6 @@ class EffectsBase {
EffectsMixin<Var, NestedEffectsBase<Var, kNoVar>, Effects<Var, kNoVar> >;
Zone* zone() { return map_->allocator().zone(); }
Isolate* isolate() { return zone()->isolate(); }
struct SplayTreeConfig {
typedef Var Key;
@ -277,7 +276,6 @@ class NestedEffectsBase {
typedef typename EffectsBase<Var, kNoVar>::Locator Locator;
Zone* zone() { return node_->zone; }
Isolate* isolate() { return zone()->isolate(); }
void push() { node_ = new(node_->zone) Node(node_->zone, node_); }
void pop() { node_ = node_->previous; }

View File

@ -421,7 +421,7 @@ void FullCodeGenerator::Initialize() {
!Snapshot::HaveASnapshotToStartFrom();
masm_->set_emit_debug_code(generate_debug_code_);
masm_->set_predictable_code_size(true);
InitializeAstVisitor(info_->isolate());
InitializeAstVisitor(info_->zone());
}
@ -847,7 +847,7 @@ void FullCodeGenerator::SetStatementPosition(Statement* stmt) {
} else {
// Check if the statement will be breakable without adding a debug break
// slot.
BreakableStatementChecker checker(isolate());
BreakableStatementChecker checker(zone());
checker.Check(stmt);
// Record the statement position right here if the statement is not
// breakable. For breakable statements the actual recording of the
@ -873,7 +873,7 @@ void FullCodeGenerator::SetExpressionPosition(Expression* expr) {
} else {
// Check if the expression will be breakable without adding a debug break
// slot.
BreakableStatementChecker checker(isolate());
BreakableStatementChecker checker(zone());
checker.Check(expr);
// Record a statement position right here if the expression is not
// breakable. For breakable expressions the actual recording of the

View File

@ -52,8 +52,8 @@ class JumpPatchSite;
// debugger to piggybag on.
class BreakableStatementChecker: public AstVisitor {
public:
explicit BreakableStatementChecker(Isolate* isolate) : is_breakable_(false) {
InitializeAstVisitor(isolate);
explicit BreakableStatementChecker(Zone* zone) : is_breakable_(false) {
InitializeAstVisitor(zone);
}
void Check(Statement* stmt);
@ -99,8 +99,7 @@ class FullCodeGenerator: public AstVisitor {
type_feedback_cells_(info->HasDeoptimizationSupport()
? info->function()->ast_node_count() : 0,
info->zone()),
ic_total_count_(0),
zone_(info->zone()) {
ic_total_count_(0) {
Initialize();
}
@ -122,8 +121,6 @@ class FullCodeGenerator: public AstVisitor {
return NULL;
}
Zone* zone() const { return zone_; }
static const int kMaxBackEdgeWeight = 127;
// Platform-specific code size multiplier.
@ -853,7 +850,6 @@ class FullCodeGenerator: public AstVisitor {
Handle<FixedArray> handler_table_;
Handle<Cell> profiling_counter_;
bool generate_debug_code_;
Zone* zone_;
friend class NestedStatement;

View File

@ -2980,7 +2980,7 @@ MaybeObject* Heap::AllocatePropertyCell() {
cell->set_dependent_code(DependentCode::cast(empty_fixed_array()),
SKIP_WRITE_BARRIER);
cell->set_value(the_hole_value());
cell->set_type(Type::None());
cell->set_type(HeapType::None());
return result;
}

View File

@ -1557,8 +1557,7 @@ HValue* HGraphBuilder::BuildUncheckedDictionaryElementLoad(HValue* receiver,
}
HValue* HGraphBuilder::BuildNumberToString(HValue* object,
Handle<Type> type) {
HValue* HGraphBuilder::BuildNumberToString(HValue* object, Type* type) {
NoObservableSideEffectsScope scope(this);
// Convert constant numbers at compile time.
@ -2584,7 +2583,7 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HValue* boilerplate,
void HGraphBuilder::BuildCompareNil(
HValue* value,
Handle<Type> type,
Type* type,
HIfContinuation* continuation) {
IfBuilder if_nil(this);
bool some_case_handled = false;
@ -2902,7 +2901,7 @@ HOptimizedGraphBuilder::HOptimizedGraphBuilder(CompilationInfo* info)
// constructor for the initial state relies on function_state_ == NULL
// to know it's the initial state.
function_state_= &initial_function_state_;
InitializeAstVisitor(info->isolate());
InitializeAstVisitor(info->zone());
if (FLAG_emit_opt_code_positions) {
SetSourcePosition(info->shared_info()->start_position());
}
@ -4233,7 +4232,7 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
CHECK_ALIVE(VisitForValue(stmt->tag()));
Add<HSimulate>(stmt->EntryId());
HValue* tag_value = Top();
Handle<Type> tag_type = stmt->tag()->bounds().lower;
Type* tag_type = stmt->tag()->bounds().lower;
// 1. Build all the tests, with dangling true branches
BailoutId default_id = BailoutId::None();
@ -4249,8 +4248,8 @@ void HOptimizedGraphBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
CHECK_ALIVE(VisitForValue(clause->label()));
HValue* label_value = Pop();
Handle<Type> label_type = clause->label()->bounds().lower;
Handle<Type> combined_type = clause->compare_type();
Type* label_type = clause->label()->bounds().lower;
Type* combined_type = clause->compare_type();
HControlInstruction* compare = BuildCompareInstruction(
Token::EQ_STRICT, tag_value, label_value, tag_type, label_type,
combined_type, stmt->tag()->position(), clause->label()->position(),
@ -8590,8 +8589,7 @@ HInstruction* HOptimizedGraphBuilder::BuildIncrement(
bool returns_original_input,
CountOperation* expr) {
// The input to the count operation is on top of the expression stack.
Handle<Type> info = expr->type();
Representation rep = Representation::FromType(info);
Representation rep = Representation::FromType(expr->type());
if (rep.IsNone() || rep.IsTagged()) {
rep = Representation::Smi();
}
@ -8842,7 +8840,7 @@ bool CanBeZero(HValue* right) {
HValue* HGraphBuilder::EnforceNumberType(HValue* number,
Handle<Type> expected) {
Type* expected) {
if (expected->Is(Type::Smi())) {
return AddUncasted<HForceRepresentation>(number, Representation::Smi());
}
@ -8854,12 +8852,12 @@ HValue* HGraphBuilder::EnforceNumberType(HValue* number,
}
HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) {
HValue* HGraphBuilder::TruncateToNumber(HValue* value, Type** expected) {
if (value->IsConstant()) {
HConstant* constant = HConstant::cast(value);
Maybe<HConstant*> number = constant->CopyToTruncatedNumber(zone());
if (number.has_value) {
*expected = Type::Number(isolate());
*expected = Type::Number(zone());
return AddInstruction(number.value);
}
}
@ -8869,25 +8867,24 @@ HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) {
// pushes with a NoObservableSideEffectsScope.
NoObservableSideEffectsScope no_effects(this);
Handle<Type> expected_type = *expected;
Type* expected_type = *expected;
// Separate the number type from the rest.
Handle<Type> expected_obj = Type::Intersect(
expected_type, Type::NonNumber(isolate()), isolate());
Handle<Type> expected_number = Type::Intersect(
expected_type, Type::Number(isolate()), isolate());
Type* expected_obj =
Type::Intersect(expected_type, Type::NonNumber(zone()), zone());
Type* expected_number =
Type::Intersect(expected_type, Type::Number(zone()), zone());
// We expect to get a number.
// (We need to check first, since Type::None->Is(Type::Any()) == true.
if (expected_obj->Is(Type::None())) {
ASSERT(!expected_number->Is(Type::None()));
ASSERT(!expected_number->Is(Type::None(zone())));
return value;
}
if (expected_obj->Is(Type::Undefined())) {
if (expected_obj->Is(Type::Undefined(zone()))) {
// This is already done by HChange.
*expected = Type::Union(
expected_number, Type::Double(isolate()), isolate());
*expected = Type::Union(expected_number, Type::Double(zone()), zone());
return value;
}
@ -8899,9 +8896,9 @@ HValue* HOptimizedGraphBuilder::BuildBinaryOperation(
BinaryOperation* expr,
HValue* left,
HValue* right) {
Handle<Type> left_type = expr->left()->bounds().lower;
Handle<Type> right_type = expr->right()->bounds().lower;
Handle<Type> result_type = expr->bounds().lower;
Type* left_type = expr->left()->bounds().lower;
Type* right_type = expr->right()->bounds().lower;
Type* result_type = expr->bounds().lower;
Maybe<int> fixed_right_arg = expr->fixed_right_arg();
Handle<AllocationSite> allocation_site = expr->allocation_site();
@ -8931,9 +8928,9 @@ HValue* HGraphBuilder::BuildBinaryOperation(
Token::Value op,
HValue* left,
HValue* right,
Handle<Type> left_type,
Handle<Type> right_type,
Handle<Type> result_type,
Type* left_type,
Type* right_type,
Type* result_type,
Maybe<int> fixed_right_arg,
HAllocationMode allocation_mode) {
@ -8949,7 +8946,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(
Deoptimizer::SOFT);
// TODO(rossberg): we should be able to get rid of non-continuous
// defaults.
left_type = Type::Any(isolate());
left_type = Type::Any(zone());
} else {
if (!maybe_string_add) left = TruncateToNumber(left, &left_type);
left_rep = Representation::FromType(left_type);
@ -8958,7 +8955,7 @@ HValue* HGraphBuilder::BuildBinaryOperation(
if (right_type->Is(Type::None())) {
Add<HDeoptimize>("Insufficient type feedback for RHS of binary operation",
Deoptimizer::SOFT);
right_type = Type::Any(isolate());
right_type = Type::Any(zone());
} else {
if (!maybe_string_add) right = TruncateToNumber(right, &right_type);
right_rep = Representation::FromType(right_type);
@ -9366,9 +9363,9 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
return ast_context()->ReturnControl(instr, expr->id());
}
Handle<Type> left_type = expr->left()->bounds().lower;
Handle<Type> right_type = expr->right()->bounds().lower;
Handle<Type> combined_type = expr->combined_type();
Type* left_type = expr->left()->bounds().lower;
Type* right_type = expr->right()->bounds().lower;
Type* combined_type = expr->combined_type();
CHECK_ALIVE(VisitForValue(expr->left()));
CHECK_ALIVE(VisitForValue(expr->right()));
@ -9445,9 +9442,9 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
Token::Value op,
HValue* left,
HValue* right,
Handle<Type> left_type,
Handle<Type> right_type,
Handle<Type> combined_type,
Type* left_type,
Type* right_type,
Type* combined_type,
int left_position,
int right_position,
BailoutId bailout_id) {
@ -9457,7 +9454,7 @@ HControlInstruction* HOptimizedGraphBuilder::BuildCompareInstruction(
Add<HDeoptimize>("Insufficient type feedback for combined type "
"of binary operation",
Deoptimizer::SOFT);
combined_type = left_type = right_type = Type::Any(isolate());
combined_type = left_type = right_type = Type::Any(zone());
}
Representation left_rep = Representation::FromType(left_type);
@ -9553,8 +9550,8 @@ void HOptimizedGraphBuilder::HandleLiteralCompareNil(CompareOperation* expr,
return ast_context()->ReturnControl(instr, expr->id());
} else {
ASSERT_EQ(Token::EQ, expr->op());
Handle<Type> type = expr->combined_type()->Is(Type::None())
? Type::Any(isolate_) : expr->combined_type();
Type* type = expr->combined_type()->Is(Type::None())
? Type::Any(zone()) : expr->combined_type();
HIfContinuation continuation;
BuildCompareNil(value, type, &continuation);
return ast_context()->ReturnContinuation(&continuation, expr->id());
@ -10324,7 +10321,7 @@ void HOptimizedGraphBuilder::GenerateNumberToString(CallRuntime* call) {
ASSERT_EQ(1, call->arguments()->length());
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
HValue* number = Pop();
HValue* result = BuildNumberToString(number, Type::Any(isolate()));
HValue* result = BuildNumberToString(number, Type::Any(zone()));
return ast_context()->ReturnValue(result);
}

View File

@ -1306,7 +1306,7 @@ class HGraphBuilder {
ElementsKind to_kind,
bool is_jsarray);
HValue* BuildNumberToString(HValue* object, Handle<Type> type);
HValue* BuildNumberToString(HValue* object, Type* type);
HValue* BuildUncheckedDictionaryElementLoad(HValue* receiver,
HValue* key);
@ -1386,9 +1386,9 @@ class HGraphBuilder {
HValue* BuildBinaryOperation(Token::Value op,
HValue* left,
HValue* right,
Handle<Type> left_type,
Handle<Type> right_type,
Handle<Type> result_type,
Type* left_type,
Type* right_type,
Type* result_type,
Maybe<int> fixed_right_arg,
HAllocationMode allocation_mode);
@ -1396,8 +1396,8 @@ class HGraphBuilder {
HValue* AddLoadJSBuiltin(Builtins::JavaScript builtin);
HValue* EnforceNumberType(HValue* number, Handle<Type> expected);
HValue* TruncateToNumber(HValue* value, Handle<Type>* expected);
HValue* EnforceNumberType(HValue* number, Type* expected);
HValue* TruncateToNumber(HValue* value, Type** expected);
void FinishExitWithHardDeoptimization(const char* reason,
HBasicBlock* continuation);
@ -1753,7 +1753,7 @@ class HGraphBuilder {
void BuildCompareNil(
HValue* value,
Handle<Type> type,
Type* type,
HIfContinuation* continuation);
void BuildCreateAllocationMemento(HValue* previous_object,
@ -2368,9 +2368,9 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
HControlInstruction* BuildCompareInstruction(Token::Value op,
HValue* left,
HValue* right,
Handle<Type> left_type,
Handle<Type> right_type,
Handle<Type> combined_type,
Type* left_type,
Type* right_type,
Type* combined_type,
int left_position,
int right_position,
BailoutId bailout_id);

View File

@ -1143,7 +1143,7 @@ void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
#define __ ACCESS_MASM(masm())
Register StubCompiler::CheckPrototypes(Handle<Type> type,
Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Register holder_reg,
@ -1281,7 +1281,7 @@ void StoreStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
Register LoadStubCompiler::CallbackHandlerFrontend(
Handle<Type> type,
Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,
@ -1978,7 +1978,7 @@ Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
}
Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<Type> type,
Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<HeapType> type,
Handle<JSObject> last,
Handle<Name> name) {
NonexistentHandlerFrontend(type, last, name);
@ -2056,7 +2056,7 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
Handle<Code> LoadStubCompiler::CompileLoadGlobal(
Handle<Type> type,
Handle<HeapType> type,
Handle<GlobalObject> global,
Handle<PropertyCell> cell,
Handle<Name> name,
@ -2116,12 +2116,12 @@ Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
int receiver_count = types->length();
int number_of_handled_maps = 0;
for (int current = 0; current < receiver_count; ++current) {
Handle<Type> type = types->at(current);
Handle<HeapType> type = types->at(current);
Handle<Map> map = IC::TypeToMap(*type, isolate());
if (!map->is_deprecated()) {
number_of_handled_maps++;
__ cmp(map_reg, map);
if (type->Is(Type::Number())) {
if (type->Is(HeapType::Number())) {
ASSERT(!number_case.is_unused());
__ bind(&number_case);
}

View File

@ -111,8 +111,8 @@ InlineCacheHolderFlag IC::GetCodeCacheForObject(Object* object) {
HeapObject* IC::GetCodeCacheHolder(Isolate* isolate,
Object* object,
InlineCacheHolderFlag holder) {
Object* object,
InlineCacheHolderFlag holder) {
if (object->IsSmi()) holder = PROTOTYPE_MAP;
Object* map_owner = holder == OWN_MAP
? object : object->GetPrototype(isolate);
@ -120,11 +120,11 @@ HeapObject* IC::GetCodeCacheHolder(Isolate* isolate,
}
InlineCacheHolderFlag IC::GetCodeCacheFlag(Type* type) {
if (type->Is(Type::Boolean()) ||
type->Is(Type::Number()) ||
type->Is(Type::String()) ||
type->Is(Type::Symbol())) {
InlineCacheHolderFlag IC::GetCodeCacheFlag(HeapType* type) {
if (type->Is(HeapType::Boolean()) ||
type->Is(HeapType::Number()) ||
type->Is(HeapType::String()) ||
type->Is(HeapType::Symbol())) {
return PROTOTYPE_MAP;
}
return OWN_MAP;
@ -132,19 +132,19 @@ InlineCacheHolderFlag IC::GetCodeCacheFlag(Type* type) {
Handle<Map> IC::GetCodeCacheHolder(InlineCacheHolderFlag flag,
Type* type,
HeapType* type,
Isolate* isolate) {
if (flag == PROTOTYPE_MAP) {
Context* context = isolate->context()->native_context();
JSFunction* constructor;
if (type->Is(Type::Boolean())) {
if (type->Is(HeapType::Boolean())) {
constructor = context->boolean_function();
} else if (type->Is(Type::Number())) {
} else if (type->Is(HeapType::Number())) {
constructor = context->number_function();
} else if (type->Is(Type::String())) {
} else if (type->Is(HeapType::String())) {
constructor = context->string_function();
} else {
ASSERT(type->Is(Type::Symbol()));
ASSERT(type->Is(HeapType::Symbol()));
constructor = context->symbol_function();
}
return handle(JSObject::cast(constructor->instance_prototype())->map());

109
src/ic.cc
View File

@ -898,7 +898,7 @@ static bool AddOneReceiverMapIfMissing(MapHandleList* receiver_maps,
}
bool IC::UpdatePolymorphicIC(Handle<Type> type,
bool IC::UpdatePolymorphicIC(Handle<HeapType> type,
Handle<String> name,
Handle<Code> code) {
if (!code->is_handler()) return false;
@ -913,7 +913,7 @@ bool IC::UpdatePolymorphicIC(Handle<Type> type,
number_of_valid_types = number_of_types;
for (int i = 0; i < number_of_types; i++) {
Handle<Type> current_type = types.at(i);
Handle<HeapType> current_type = types.at(i);
// Filter out deprecated maps to ensure their instances get migrated.
if (current_type->IsClass() && current_type->AsClass()->is_deprecated()) {
number_of_valid_types--;
@ -946,16 +946,17 @@ bool IC::UpdatePolymorphicIC(Handle<Type> type,
}
Handle<Type> IC::CurrentTypeOf(Handle<Object> object, Isolate* isolate) {
Handle<HeapType> IC::CurrentTypeOf(Handle<Object> object, Isolate* isolate) {
return object->IsJSGlobalObject()
? Type::Constant(Handle<JSGlobalObject>::cast(object), isolate)
: Type::OfCurrently(object, isolate);
? HeapType::Constant(Handle<JSGlobalObject>::cast(object), isolate)
: HeapType::OfCurrently(object, isolate);
}
Handle<Map> IC::TypeToMap(Type* type, Isolate* isolate) {
if (type->Is(Type::Number())) return isolate->factory()->heap_number_map();
if (type->Is(Type::Boolean())) return isolate->factory()->oddball_map();
Handle<Map> IC::TypeToMap(HeapType* type, Isolate* isolate) {
if (type->Is(HeapType::Number()))
return isolate->factory()->heap_number_map();
if (type->Is(HeapType::Boolean())) return isolate->factory()->oddball_map();
if (type->IsConstant()) {
return handle(Handle<JSGlobalObject>::cast(type->AsConstant())->map());
}
@ -964,16 +965,20 @@ Handle<Map> IC::TypeToMap(Type* type, Isolate* isolate) {
}
Handle<Type> IC::MapToType(Handle<Map> map) {
Handle<HeapType> IC::MapToType(Handle<Map> map) {
Isolate* isolate = map->GetIsolate();
if (map->instance_type() == HEAP_NUMBER_TYPE) return Type::Number(isolate);
// The only oddballs that can be recorded in ICs are booleans.
if (map->instance_type() == ODDBALL_TYPE) return Type::Boolean(isolate);
return Type::Class(map, isolate);
if (map->instance_type() == HEAP_NUMBER_TYPE) {
return HeapType::Number(isolate);
} else if (map->instance_type() == ODDBALL_TYPE) {
// The only oddballs that can be recorded in ICs are booleans.
return HeapType::Boolean(isolate);
} else {
return HeapType::Class(map, isolate);
}
}
void IC::UpdateMonomorphicIC(Handle<Type> type,
void IC::UpdateMonomorphicIC(Handle<HeapType> type,
Handle<Code> handler,
Handle<String> name) {
if (!handler->is_handler()) return set_target(*handler);
@ -994,7 +999,7 @@ void IC::CopyICToMegamorphicCache(Handle<String> name) {
}
bool IC::IsTransitionOfMonomorphicTarget(Handle<Type> type) {
bool IC::IsTransitionOfMonomorphicTarget(Handle<HeapType> type) {
if (!type->IsClass()) return false;
Map* receiver_map = *type->AsClass();
Map* current_map = target()->FindFirstMap();
@ -1010,7 +1015,7 @@ bool IC::IsTransitionOfMonomorphicTarget(Handle<Type> type) {
}
void IC::PatchCache(Handle<Type> type,
void IC::PatchCache(Handle<HeapType> type,
Handle<String> name,
Handle<Code> code) {
switch (state()) {
@ -1096,7 +1101,7 @@ void LoadIC::UpdateCaches(LookupResult* lookup,
return;
}
Handle<Type> type = CurrentTypeOf(object, isolate());
Handle<HeapType> type = CurrentTypeOf(object, isolate());
Handle<Code> code;
if (!lookup->IsCacheable()) {
// Bail out if the result is not cacheable.
@ -1116,7 +1121,7 @@ void LoadIC::UpdateCaches(LookupResult* lookup,
}
void IC::UpdateMegamorphicCache(Type* type, Name* name, Code* code) {
void IC::UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {
// Cache code holding map should be consistent with
// GenerateMonomorphicCacheProbe.
Map* map = *TypeToMap(type, isolate());
@ -1157,7 +1162,7 @@ Handle<Code> LoadIC::CompileHandler(LookupResult* lookup,
return SimpleFieldLoad(length_index);
}
Handle<Type> type = CurrentTypeOf(object, isolate());
Handle<HeapType> type = CurrentTypeOf(object, isolate());
Handle<JSObject> holder(lookup->holder());
LoadStubCompiler compiler(isolate(), kNoExtraICState, cache_holder, kind());
@ -1629,7 +1634,7 @@ Handle<Code> StoreIC::CompileHandler(LookupResult* lookup,
// global object.
Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver);
Handle<PropertyCell> cell(global->GetPropertyCell(lookup), isolate());
Handle<Type> union_type = PropertyCell::UpdatedType(cell, value);
Handle<HeapType> union_type = PropertyCell::UpdatedType(cell, value);
StoreGlobalStub stub(union_type->IsConstant());
Handle<Code> code = stub.GetCodeCopyFromTemplate(
@ -2563,17 +2568,17 @@ void BinaryOpIC::State::GenerateAheadOfTime(
}
Handle<Type> BinaryOpIC::State::GetResultType(Isolate* isolate) const {
Type* BinaryOpIC::State::GetResultType(Zone* zone) const {
Kind result_kind = result_kind_;
if (HasSideEffects()) {
result_kind = NONE;
} else if (result_kind == GENERIC && op_ == Token::ADD) {
return Type::Union(Type::Number(isolate), Type::String(isolate), isolate);
return Type::Union(Type::Number(zone), Type::String(zone), zone);
} else if (result_kind == NUMBER && op_ == Token::SHR) {
return Type::Unsigned32(isolate);
return Type::Unsigned32(zone);
}
ASSERT_NE(GENERIC, result_kind);
return KindToType(result_kind, isolate);
return KindToType(result_kind, zone);
}
@ -2704,17 +2709,17 @@ const char* BinaryOpIC::State::KindToString(Kind kind) {
// static
Handle<Type> BinaryOpIC::State::KindToType(Kind kind, Isolate* isolate) {
Type* BinaryOpIC::State::KindToType(Kind kind, Zone* zone) {
switch (kind) {
case NONE: return Type::None(isolate);
case SMI: return Type::Smi(isolate);
case INT32: return Type::Signed32(isolate);
case NUMBER: return Type::Number(isolate);
case STRING: return Type::String(isolate);
case GENERIC: return Type::Any(isolate);
case NONE: return Type::None(zone);
case SMI: return Type::Smi(zone);
case INT32: return Type::Signed32(zone);
case NUMBER: return Type::Number(zone);
case STRING: return Type::String(zone);
case GENERIC: return Type::Any(zone);
}
UNREACHABLE();
return Handle<Type>();
return NULL;
}
@ -2844,41 +2849,39 @@ const char* CompareIC::GetStateName(State state) {
}
Handle<Type> CompareIC::StateToType(
Isolate* isolate,
Type* CompareIC::StateToType(
Zone* zone,
CompareIC::State state,
Handle<Map> map) {
switch (state) {
case CompareIC::UNINITIALIZED: return Type::None(isolate);
case CompareIC::SMI: return Type::Smi(isolate);
case CompareIC::NUMBER: return Type::Number(isolate);
case CompareIC::STRING: return Type::String(isolate);
case CompareIC::INTERNALIZED_STRING:
return Type::InternalizedString(isolate);
case CompareIC::UNIQUE_NAME: return Type::UniqueName(isolate);
case CompareIC::OBJECT: return Type::Receiver(isolate);
case CompareIC::UNINITIALIZED: return Type::None(zone);
case CompareIC::SMI: return Type::Smi(zone);
case CompareIC::NUMBER: return Type::Number(zone);
case CompareIC::STRING: return Type::String(zone);
case CompareIC::INTERNALIZED_STRING: return Type::InternalizedString(zone);
case CompareIC::UNIQUE_NAME: return Type::UniqueName(zone);
case CompareIC::OBJECT: return Type::Receiver(zone);
case CompareIC::KNOWN_OBJECT:
return map.is_null()
? Type::Receiver(isolate) : Type::Class(map, isolate);
case CompareIC::GENERIC: return Type::Any(isolate);
return map.is_null() ? Type::Receiver(zone) : Type::Class(map, zone);
case CompareIC::GENERIC: return Type::Any(zone);
}
UNREACHABLE();
return Handle<Type>();
return NULL;
}
void CompareIC::StubInfoToType(int stub_minor_key,
Handle<Type>* left_type,
Handle<Type>* right_type,
Handle<Type>* overall_type,
Type** left_type,
Type** right_type,
Type** overall_type,
Handle<Map> map,
Isolate* isolate) {
Zone* zone) {
State left_state, right_state, handler_state;
ICCompareStub::DecodeMinorKey(stub_minor_key, &left_state, &right_state,
&handler_state, NULL);
*left_type = StateToType(isolate, left_state);
*right_type = StateToType(isolate, right_state);
*overall_type = StateToType(isolate, handler_state, map);
*left_type = StateToType(zone, left_state);
*right_type = StateToType(zone, right_state);
*overall_type = StateToType(zone, handler_state, map);
}

View File

@ -130,9 +130,9 @@ class IC {
Object* object,
InlineCacheHolderFlag holder);
static inline InlineCacheHolderFlag GetCodeCacheFlag(Type* type);
static inline InlineCacheHolderFlag GetCodeCacheFlag(HeapType* type);
static inline Handle<Map> GetCodeCacheHolder(InlineCacheHolderFlag flag,
Type* type,
HeapType* type,
Isolate* isolate);
static bool IsCleared(Code* code) {
@ -145,9 +145,10 @@ class IC {
// - The heap_number_map is used as a marker which includes heap numbers as
// well as smis.
// - The oddball map is only used for booleans.
static Handle<Map> TypeToMap(Type* type, Isolate* isolate);
static Handle<Type> MapToType(Handle<Map> type);
static Handle<Type> CurrentTypeOf(Handle<Object> object, Isolate* isolate);
static Handle<Map> TypeToMap(HeapType* type, Isolate* isolate);
static Handle<HeapType> MapToType(Handle<Map> map);
static Handle<HeapType> CurrentTypeOf(
Handle<Object> object, Isolate* isolate);
protected:
// Get the call-site target; used for determining the state.
@ -201,19 +202,19 @@ class IC {
return Handle<Code>::null();
}
void UpdateMonomorphicIC(Handle<Type> type,
void UpdateMonomorphicIC(Handle<HeapType> type,
Handle<Code> handler,
Handle<String> name);
bool UpdatePolymorphicIC(Handle<Type> type,
bool UpdatePolymorphicIC(Handle<HeapType> type,
Handle<String> name,
Handle<Code> code);
virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code);
virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code);
void CopyICToMegamorphicCache(Handle<String> name);
bool IsTransitionOfMonomorphicTarget(Handle<Type> type);
void PatchCache(Handle<Type> type,
bool IsTransitionOfMonomorphicTarget(Handle<HeapType> type);
void PatchCache(Handle<HeapType> type,
Handle<String> name,
Handle<Code> code);
virtual Code::Kind kind() const {
@ -536,7 +537,7 @@ class KeyedLoadIC: public LoadIC {
return isolate()->builtins()->KeyedLoadIC_Slow();
}
virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { }
virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {}
private:
// Stub accessors.
@ -708,7 +709,7 @@ class KeyedStoreIC: public StoreIC {
protected:
virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; }
virtual void UpdateMegamorphicCache(Type* type, Name* name, Code* code) { }
virtual void UpdateMegamorphicCache(HeapType* type, Name* name, Code* code) {}
virtual Handle<Code> pre_monomorphic_stub() {
return pre_monomorphic_stub(isolate(), strict_mode());
@ -843,13 +844,13 @@ class BinaryOpIC: public IC {
OverwriteMode mode() const { return mode_; }
Maybe<int> fixed_right_arg() const { return fixed_right_arg_; }
Handle<Type> GetLeftType(Isolate* isolate) const {
return KindToType(left_kind_, isolate);
Type* GetLeftType(Zone* zone) const {
return KindToType(left_kind_, zone);
}
Handle<Type> GetRightType(Isolate* isolate) const {
return KindToType(right_kind_, isolate);
Type* GetRightType(Zone* zone) const {
return KindToType(right_kind_, zone);
}
Handle<Type> GetResultType(Isolate* isolate) const;
Type* GetResultType(Zone* zone) const;
void Print(StringStream* stream) const;
@ -863,7 +864,7 @@ class BinaryOpIC: public IC {
Kind UpdateKind(Handle<Object> object, Kind kind) const;
static const char* KindToString(Kind kind);
static Handle<Type> KindToType(Kind kind, Isolate* isolate);
static Type* KindToType(Kind kind, Zone* zone);
static bool KindMaybeSmi(Kind kind) {
return (kind >= SMI && kind <= NUMBER) || kind == GENERIC;
}
@ -921,16 +922,16 @@ class CompareIC: public IC {
static State NewInputState(State old_state, Handle<Object> value);
static Handle<Type> StateToType(Isolate* isolate,
State state,
Handle<Map> map = Handle<Map>());
static Type* StateToType(Zone* zone,
State state,
Handle<Map> map = Handle<Map>());
static void StubInfoToType(int stub_minor_key,
Handle<Type>* left_type,
Handle<Type>* right_type,
Handle<Type>* overall_type,
Type** left_type,
Type** right_type,
Type** overall_type,
Handle<Map> map,
Isolate* isolate);
Zone* zone);
CompareIC(Isolate* isolate, Token::Value op)
: IC(EXTRA_CALL_FRAME, isolate), op_(op) { }

View File

@ -206,13 +206,13 @@ size_t GetMemoryUsedByList(const List<T, P>& list) {
class Map;
template<class> class TypeImpl;
struct HeapTypeConfig;
typedef TypeImpl<HeapTypeConfig> Type;
typedef TypeImpl<HeapTypeConfig> HeapType;
class Code;
template<typename T> class Handle;
typedef List<Map*> MapList;
typedef List<Code*> CodeList;
typedef List<Handle<Map> > MapHandleList;
typedef List<Handle<Type> > TypeHandleList;
typedef List<Handle<HeapType> > TypeHandleList;
typedef List<Handle<Code> > CodeHandleList;
// Perform binary search for an element in an already sorted

View File

@ -16541,25 +16541,25 @@ void JSTypedArray::Neuter() {
}
Type* PropertyCell::type() {
return static_cast<Type*>(type_raw());
HeapType* PropertyCell::type() {
return static_cast<HeapType*>(type_raw());
}
void PropertyCell::set_type(Type* type, WriteBarrierMode ignored) {
void PropertyCell::set_type(HeapType* type, WriteBarrierMode ignored) {
ASSERT(IsPropertyCell());
set_type_raw(type, ignored);
}
Handle<Type> PropertyCell::UpdatedType(Handle<PropertyCell> cell,
Handle<Object> value) {
Handle<HeapType> PropertyCell::UpdatedType(Handle<PropertyCell> cell,
Handle<Object> value) {
Isolate* isolate = cell->GetIsolate();
Handle<Type> old_type(cell->type(), isolate);
Handle<HeapType> old_type(cell->type(), isolate);
// TODO(2803): Do not track ConsString as constant because they cannot be
// embedded into code.
Handle<Type> new_type = value->IsConsString() || value->IsTheHole()
? Type::Any(isolate) : Type::Constant(value, isolate);
Handle<HeapType> new_type = value->IsConsString() || value->IsTheHole()
? HeapType::Any(isolate) : HeapType::Constant(value, isolate);
if (new_type->Is(old_type)) {
return old_type;
@ -16568,19 +16568,19 @@ Handle<Type> PropertyCell::UpdatedType(Handle<PropertyCell> cell,
cell->dependent_code()->DeoptimizeDependentCodeGroup(
isolate, DependentCode::kPropertyCellChangedGroup);
if (old_type->Is(Type::None()) || old_type->Is(Type::Undefined())) {
if (old_type->Is(HeapType::None()) || old_type->Is(HeapType::Undefined())) {
return new_type;
}
return Type::Any(isolate);
return HeapType::Any(isolate);
}
void PropertyCell::SetValueInferType(Handle<PropertyCell> cell,
Handle<Object> value) {
cell->set_value(*value);
if (!Type::Any()->Is(cell->type())) {
Handle<Type> new_type = UpdatedType(cell, value);
if (!HeapType::Any()->Is(cell->type())) {
Handle<HeapType> new_type = UpdatedType(cell, value);
cell->set_type(*new_type);
}
}

View File

@ -906,10 +906,10 @@ class FixedArrayBase;
class GlobalObject;
class ObjectVisitor;
class StringStream;
// We cannot just say "class Type;" if it is created from a template... =8-?
// We cannot just say "class HeapType;" if it is created from a template... =8-?
template<class> class TypeImpl;
struct HeapTypeConfig;
typedef TypeImpl<HeapTypeConfig> Type;
typedef TypeImpl<HeapTypeConfig> HeapType;
// A template-ized version of the IsXXX functions.
@ -9512,8 +9512,8 @@ class Cell: public HeapObject {
class PropertyCell: public Cell {
public:
// [type]: type of the global property.
Type* type();
void set_type(Type* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
HeapType* type();
void set_type(HeapType* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
// [dependent_code]: dependent code that depends on the type of the global
// property.
@ -9528,8 +9528,8 @@ class PropertyCell: public Cell {
// Computes the new type of the cell's contents for the given value, but
// without actually modifying the 'type' field.
static Handle<Type> UpdatedType(Handle<PropertyCell> cell,
Handle<Object> value);
static Handle<HeapType> UpdatedType(Handle<PropertyCell> cell,
Handle<Object> value);
void AddDependentCompilationInfo(CompilationInfo* info);

View File

@ -485,9 +485,7 @@ class Parser::BlockState BASE_EMBEDDED {
};
Parser::FunctionState::FunctionState(Parser* parser,
Scope* scope,
Isolate* isolate)
Parser::FunctionState::FunctionState(Parser* parser, Scope* scope)
: next_materialized_literal_index_(JSFunction::kLiteralsPrefixSize),
next_handler_index_(0),
expected_property_count_(0),
@ -495,11 +493,11 @@ Parser::FunctionState::FunctionState(Parser* parser,
parser_(parser),
outer_function_state_(parser->current_function_state_),
outer_scope_(parser->top_scope_),
saved_ast_node_id_(isolate->ast_node_id()),
factory_(isolate, parser->zone()) {
saved_ast_node_id_(parser->zone()->isolate()->ast_node_id()),
factory_(parser->zone()) {
parser->top_scope_ = scope;
parser->current_function_state_ = this;
isolate->set_ast_node_id(BailoutId::FirstUsable().ToInt());
parser->zone()->isolate()->set_ast_node_id(BailoutId::FirstUsable().ToInt());
}
@ -645,7 +643,7 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info,
ParsingModeScope parsing_mode(this, mode);
// Enters 'scope'.
FunctionState function_state(this, scope, isolate());
FunctionState function_state(this, scope);
top_scope_->SetLanguageMode(info->language_mode());
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
@ -759,7 +757,7 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) {
zone());
}
original_scope_ = scope;
FunctionState function_state(this, scope, isolate());
FunctionState function_state(this, scope);
ASSERT(scope->language_mode() != STRICT_MODE || !info()->is_classic_mode());
ASSERT(scope->language_mode() != EXTENDED_MODE ||
info()->is_extended_mode());
@ -3835,7 +3833,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) {
Expression* value = ParseAssignmentExpression(true, CHECK_OK);
ObjectLiteral::Property* property =
new(zone()) ObjectLiteral::Property(key, value, isolate());
factory()->NewObjectLiteralProperty(key, value);
// Mark top-level object literals that contain function literals and
// pretenure the literal so it can be added as a constant function
@ -4084,7 +4082,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
AstProperties ast_properties;
BailoutReason dont_optimize_reason = kNoReason;
// Parse function body.
{ FunctionState function_state(this, scope, isolate());
{ FunctionState function_state(this, scope);
top_scope_->SetScopeName(function_name);
if (is_generator) {

View File

@ -451,9 +451,7 @@ class Parser : public ParserBase {
class FunctionState BASE_EMBEDDED {
public:
FunctionState(Parser* parser,
Scope* scope,
Isolate* isolate);
FunctionState(Parser* parser, Scope* scope);
~FunctionState();
int NextMaterializedLiteralIndex() {

View File

@ -38,11 +38,11 @@ namespace internal {
#ifdef DEBUG
PrettyPrinter::PrettyPrinter(Isolate* isolate) {
PrettyPrinter::PrettyPrinter(Zone* zone) {
output_ = NULL;
size_ = 0;
pos_ = 0;
InitializeAstVisitor(isolate);
InitializeAstVisitor(zone);
}
@ -493,8 +493,8 @@ const char* PrettyPrinter::PrintProgram(FunctionLiteral* program) {
}
void PrettyPrinter::PrintOut(Isolate* isolate, AstNode* node) {
PrettyPrinter printer(isolate);
void PrettyPrinter::PrintOut(Zone* zone, AstNode* node) {
PrettyPrinter printer(zone);
PrintF("%s", printer.Print(node));
}
@ -657,7 +657,7 @@ class IndentedScope BASE_EMBEDDED {
//-----------------------------------------------------------------------------
AstPrinter::AstPrinter(Isolate* isolate) : PrettyPrinter(isolate), indent_(0) {
AstPrinter::AstPrinter(Zone* zone) : PrettyPrinter(zone), indent_(0) {
}

View File

@ -38,7 +38,7 @@ namespace internal {
class PrettyPrinter: public AstVisitor {
public:
explicit PrettyPrinter(Isolate* isolate);
explicit PrettyPrinter(Zone* zone);
virtual ~PrettyPrinter();
// The following routines print a node into a string.
@ -50,7 +50,7 @@ class PrettyPrinter: public AstVisitor {
void Print(const char* format, ...);
// Print a node to stdout.
static void PrintOut(Isolate* isolate, AstNode* node);
static void PrintOut(Zone* zone, AstNode* node);
// Individual nodes
#define DECLARE_VISIT(type) virtual void Visit##type(type* node);
@ -82,7 +82,7 @@ class PrettyPrinter: public AstVisitor {
// Prints the AST structure
class AstPrinter: public PrettyPrinter {
public:
explicit AstPrinter(Isolate* isolate);
explicit AstPrinter(Zone* zone);
virtual ~AstPrinter();
const char* PrintProgram(FunctionLiteral* program);

View File

@ -59,8 +59,8 @@ namespace internal {
class Smi;
template<class> class TypeImpl;
struct HeapTypeConfig;
typedef TypeImpl<HeapTypeConfig> Type;
struct ZoneTypeConfig;
typedef TypeImpl<ZoneTypeConfig> Type;
class TypeInfo;
// Type of properties.
@ -116,7 +116,7 @@ class Representation {
static Representation FromKind(Kind kind) { return Representation(kind); }
static Representation FromType(Handle<Type> type);
static Representation FromType(Type* type);
bool Equals(const Representation& other) const {
return kind_ == other.kind_;

View File

@ -43,8 +43,8 @@ class Processor: public AstVisitor {
result_assigned_(false),
is_set_(false),
in_try_(false),
factory_(zone->isolate(), zone) {
InitializeAstVisitor(zone->isolate());
factory_(zone) {
InitializeAstVisitor(zone);
}
virtual ~Processor() { }

View File

@ -290,8 +290,7 @@ bool Scope::Analyze(CompilationInfo* info) {
// Allocate the variables.
{
AstNodeFactory<AstNullVisitor> ast_node_factory(info->isolate(),
info->zone());
AstNodeFactory<AstNullVisitor> ast_node_factory(info->zone());
if (!top->AllocateVariables(info, &ast_node_factory)) return false;
}

View File

@ -128,7 +128,7 @@ Handle<Code> StubCache::FindHandler(Handle<Name> name,
Handle<Code> StubCache::ComputeMonomorphicIC(
Handle<Name> name,
Handle<Type> type,
Handle<HeapType> type,
Handle<Code> handler,
ExtraICState extra_ic_state) {
Code::Kind kind = handler->handler_kind();
@ -139,7 +139,7 @@ Handle<Code> StubCache::ComputeMonomorphicIC(
// There are multiple string maps that all use the same prototype. That
// prototype cannot hold multiple handlers, one for each of the string maps,
// for a single name. Hence, turn off caching of the IC.
bool can_be_cached = !type->Is(Type::String());
bool can_be_cached = !type->Is(HeapType::String());
if (can_be_cached) {
stub_holder = IC::GetCodeCacheHolder(flag, *type, isolate());
ic = FindIC(name, stub_holder, kind, extra_ic_state, flag);
@ -169,7 +169,7 @@ Handle<Code> StubCache::ComputeMonomorphicIC(
Handle<Code> StubCache::ComputeLoadNonexistent(Handle<Name> name,
Handle<Type> type) {
Handle<HeapType> type) {
InlineCacheHolderFlag flag = IC::GetCodeCacheFlag(*type);
Handle<Map> stub_holder = IC::GetCodeCacheHolder(flag, *type, isolate());
// If no dictionary mode objects are present in the prototype chain, the load
@ -638,7 +638,7 @@ Handle<Code> StubCache::ComputeLoadElementPolymorphic(
TypeHandleList types(receiver_maps->length());
for (int i = 0; i < receiver_maps->length(); i++) {
types.Add(Type::Class(receiver_maps->at(i), isolate()));
types.Add(HeapType::Class(receiver_maps->at(i), isolate()));
}
CodeHandleList handlers(receiver_maps->length());
KeyedLoadStubCompiler compiler(isolate_);
@ -1343,20 +1343,20 @@ Handle<Code> CallStubCompiler::CompileCallConstant(
Register LoadStubCompiler::HandlerFrontendHeader(
Handle<Type> type,
Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,
Label* miss) {
PrototypeCheckType check_type = CHECK_ALL_MAPS;
int function_index = -1;
if (type->Is(Type::String())) {
if (type->Is(HeapType::String())) {
function_index = Context::STRING_FUNCTION_INDEX;
} else if (type->Is(Type::Symbol())) {
} else if (type->Is(HeapType::Symbol())) {
function_index = Context::SYMBOL_FUNCTION_INDEX;
} else if (type->Is(Type::Number())) {
} else if (type->Is(HeapType::Number())) {
function_index = Context::NUMBER_FUNCTION_INDEX;
} else if (type->Is(Type::Boolean())) {
} else if (type->Is(HeapType::Boolean())) {
// Booleans use the generic oddball map, so an additional check is needed to
// ensure the receiver is really a boolean.
GenerateBooleanCheck(object_reg, miss);
@ -1384,7 +1384,7 @@ Register LoadStubCompiler::HandlerFrontendHeader(
// HandlerFrontend for store uses the name register. It has to be restored
// before a miss.
Register StoreStubCompiler::HandlerFrontendHeader(
Handle<Type> type,
Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,
@ -1396,13 +1396,13 @@ Register StoreStubCompiler::HandlerFrontendHeader(
bool BaseLoadStoreStubCompiler::IncludesNumberType(TypeHandleList* types) {
for (int i = 0; i < types->length(); ++i) {
if (types->at(i)->Is(Type::Number())) return true;
if (types->at(i)->Is(HeapType::Number())) return true;
}
return false;
}
Register BaseLoadStoreStubCompiler::HandlerFrontend(Handle<Type> type,
Register BaseLoadStoreStubCompiler::HandlerFrontend(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name) {
@ -1416,7 +1416,7 @@ Register BaseLoadStoreStubCompiler::HandlerFrontend(Handle<Type> type,
}
void LoadStubCompiler::NonexistentHandlerFrontend(Handle<Type> type,
void LoadStubCompiler::NonexistentHandlerFrontend(Handle<HeapType> type,
Handle<JSObject> last,
Handle<Name> name) {
Label miss;
@ -1461,7 +1461,7 @@ void LoadStubCompiler::NonexistentHandlerFrontend(Handle<Type> type,
Handle<Code> LoadStubCompiler::CompileLoadField(
Handle<Type> type,
Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name,
PropertyIndex field,
@ -1481,7 +1481,7 @@ Handle<Code> LoadStubCompiler::CompileLoadField(
Handle<Code> LoadStubCompiler::CompileLoadConstant(
Handle<Type> type,
Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name,
Handle<Object> value) {
@ -1494,7 +1494,7 @@ Handle<Code> LoadStubCompiler::CompileLoadConstant(
Handle<Code> LoadStubCompiler::CompileLoadCallback(
Handle<Type> type,
Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name,
Handle<ExecutableAccessorInfo> callback) {
@ -1508,7 +1508,7 @@ Handle<Code> LoadStubCompiler::CompileLoadCallback(
Handle<Code> LoadStubCompiler::CompileLoadCallback(
Handle<Type> type,
Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name,
const CallOptimization& call_optimization) {
@ -1523,7 +1523,7 @@ Handle<Code> LoadStubCompiler::CompileLoadCallback(
Handle<Code> LoadStubCompiler::CompileLoadInterceptor(
Handle<Type> type,
Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name) {
LookupResult lookup(isolate());
@ -1576,7 +1576,7 @@ void LoadStubCompiler::GenerateLoadPostInterceptor(
Handle<Code> BaseLoadStoreStubCompiler::CompileMonomorphicIC(
Handle<Type> type,
Handle<HeapType> type,
Handle<Code> handler,
Handle<Name> name) {
TypeHandleList types(1);
@ -1589,7 +1589,7 @@ Handle<Code> BaseLoadStoreStubCompiler::CompileMonomorphicIC(
Handle<Code> LoadStubCompiler::CompileLoadViaGetter(
Handle<Type> type,
Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name,
Handle<JSFunction> getter) {

View File

@ -92,11 +92,11 @@ class StubCache {
InlineCacheHolderFlag cache_holder = OWN_MAP);
Handle<Code> ComputeMonomorphicIC(Handle<Name> name,
Handle<Type> type,
Handle<HeapType> type,
Handle<Code> handler,
ExtraICState extra_ic_state);
Handle<Code> ComputeLoadNonexistent(Handle<Name> name, Handle<Type> type);
Handle<Code> ComputeLoadNonexistent(Handle<Name> name, Handle<HeapType> type);
Handle<Code> ComputeKeyedLoadElement(Handle<Map> receiver_map);
@ -475,7 +475,7 @@ class StubCompiler BASE_EMBEDDED {
// The function can optionally (when save_at_depth !=
// kInvalidProtoDepth) save the object at the given depth by moving
// it to [esp + kPointerSize].
Register CheckPrototypes(Handle<Type> type,
Register CheckPrototypes(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Register holder_reg,
@ -530,7 +530,7 @@ class BaseLoadStoreStubCompiler: public StubCompiler {
}
virtual ~BaseLoadStoreStubCompiler() { }
Handle<Code> CompileMonomorphicIC(Handle<Type> type,
Handle<Code> CompileMonomorphicIC(Handle<HeapType> type,
Handle<Code> handler,
Handle<Name> name);
@ -552,7 +552,7 @@ class BaseLoadStoreStubCompiler: public StubCompiler {
}
protected:
virtual Register HandlerFrontendHeader(Handle<Type> type,
virtual Register HandlerFrontendHeader(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,
@ -560,7 +560,7 @@ class BaseLoadStoreStubCompiler: public StubCompiler {
virtual void HandlerFrontendFooter(Handle<Name> name, Label* miss) = 0;
Register HandlerFrontend(Handle<Type> type,
Register HandlerFrontend(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name);
@ -619,32 +619,32 @@ class LoadStubCompiler: public BaseLoadStoreStubCompiler {
cache_holder) { }
virtual ~LoadStubCompiler() { }
Handle<Code> CompileLoadField(Handle<Type> type,
Handle<Code> CompileLoadField(Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name,
PropertyIndex index,
Representation representation);
Handle<Code> CompileLoadCallback(Handle<Type> type,
Handle<Code> CompileLoadCallback(Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name,
Handle<ExecutableAccessorInfo> callback);
Handle<Code> CompileLoadCallback(Handle<Type> type,
Handle<Code> CompileLoadCallback(Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name,
const CallOptimization& call_optimization);
Handle<Code> CompileLoadConstant(Handle<Type> type,
Handle<Code> CompileLoadConstant(Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name,
Handle<Object> value);
Handle<Code> CompileLoadInterceptor(Handle<Type> type,
Handle<Code> CompileLoadInterceptor(Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name);
Handle<Code> CompileLoadViaGetter(Handle<Type> type,
Handle<Code> CompileLoadViaGetter(Handle<HeapType> type,
Handle<JSObject> holder,
Handle<Name> name,
Handle<JSFunction> getter);
@ -653,11 +653,11 @@ class LoadStubCompiler: public BaseLoadStoreStubCompiler {
Register receiver,
Handle<JSFunction> getter);
Handle<Code> CompileLoadNonexistent(Handle<Type> type,
Handle<Code> CompileLoadNonexistent(Handle<HeapType> type,
Handle<JSObject> last,
Handle<Name> name);
Handle<Code> CompileLoadGlobal(Handle<Type> type,
Handle<Code> CompileLoadGlobal(Handle<HeapType> type,
Handle<GlobalObject> holder,
Handle<PropertyCell> cell,
Handle<Name> name,
@ -670,7 +670,7 @@ class LoadStubCompiler: public BaseLoadStoreStubCompiler {
return LoadIC::GetContextualMode(extra_state());
}
virtual Register HandlerFrontendHeader(Handle<Type> type,
virtual Register HandlerFrontendHeader(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,
@ -678,12 +678,12 @@ class LoadStubCompiler: public BaseLoadStoreStubCompiler {
virtual void HandlerFrontendFooter(Handle<Name> name, Label* miss);
Register CallbackHandlerFrontend(Handle<Type> type,
Register CallbackHandlerFrontend(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,
Handle<Object> callback);
void NonexistentHandlerFrontend(Handle<Type> type,
void NonexistentHandlerFrontend(Handle<HeapType> type,
Handle<JSObject> last,
Handle<Name> name);
@ -814,7 +814,7 @@ class StoreStubCompiler: public BaseLoadStoreStubCompiler {
}
protected:
virtual Register HandlerFrontendHeader(Handle<Type> type,
virtual Register HandlerFrontendHeader(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,

View File

@ -44,10 +44,8 @@ namespace internal {
TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code,
Handle<Context> native_context,
Isolate* isolate,
Zone* zone)
: native_context_(native_context),
isolate_(isolate),
zone_(zone) {
BuildDictionary(code);
ASSERT(dictionary_->IsDictionary());
@ -65,12 +63,12 @@ Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) {
Object* value = dictionary_->ValueAt(entry);
if (value->IsCell()) {
Cell* cell = Cell::cast(value);
return Handle<Object>(cell->value(), isolate_);
return Handle<Object>(cell->value(), isolate());
} else {
return Handle<Object>(value, isolate_);
return Handle<Object>(value, isolate());
}
}
return Handle<Object>::cast(isolate_->factory()->undefined_value());
return Handle<Object>::cast(isolate()->factory()->undefined_value());
}
@ -186,7 +184,7 @@ CheckType TypeFeedbackOracle::GetCallCheckType(TypeFeedbackId id) {
Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(TypeFeedbackId id) {
Handle<Object> info = GetInfo(id);
if (info->IsAllocationSite()) {
return Handle<JSFunction>(isolate_->global_context()->array_function());
return Handle<JSFunction>(isolate()->global_context()->array_function());
} else {
return Handle<JSFunction>::cast(info);
}
@ -196,7 +194,7 @@ Handle<JSFunction> TypeFeedbackOracle::GetCallTarget(TypeFeedbackId id) {
Handle<JSFunction> TypeFeedbackOracle::GetCallNewTarget(TypeFeedbackId id) {
Handle<Object> info = GetInfo(id);
if (info->IsAllocationSite()) {
return Handle<JSFunction>(isolate_->global_context()->array_function());
return Handle<JSFunction>(isolate()->global_context()->array_function());
} else {
return Handle<JSFunction>::cast(info);
}
@ -215,7 +213,7 @@ Handle<AllocationSite> TypeFeedbackOracle::GetCallNewAllocationSite(
bool TypeFeedbackOracle::LoadIsBuiltin(
TypeFeedbackId id, Builtins::Name builtin) {
return *GetInfo(id) == isolate_->builtins()->builtin(builtin);
return *GetInfo(id) == isolate()->builtins()->builtin(builtin);
}
@ -230,13 +228,13 @@ bool TypeFeedbackOracle::LoadIsStub(TypeFeedbackId id, ICStub* stub) {
void TypeFeedbackOracle::CompareType(TypeFeedbackId id,
Handle<Type>* left_type,
Handle<Type>* right_type,
Handle<Type>* combined_type) {
Type** left_type,
Type** right_type,
Type** combined_type) {
Handle<Object> info = GetInfo(id);
if (!info->IsCode()) {
// For some comparisons we don't have ICs, e.g. LiteralCompareTypeof.
*left_type = *right_type = *combined_type = Type::None(isolate_);
*left_type = *right_type = *combined_type = Type::None(zone());
return;
}
Handle<Code> code = Handle<Code>::cast(info);
@ -253,19 +251,19 @@ void TypeFeedbackOracle::CompareType(TypeFeedbackId id,
if (code->is_compare_ic_stub()) {
int stub_minor_key = code->stub_info();
CompareIC::StubInfoToType(
stub_minor_key, left_type, right_type, combined_type, map, isolate());
stub_minor_key, left_type, right_type, combined_type, map, zone());
} else if (code->is_compare_nil_ic_stub()) {
CompareNilICStub stub(code->extended_extra_ic_state());
*combined_type = stub.GetType(isolate_, map);
*left_type = *right_type = stub.GetInputType(isolate_, map);
*combined_type = stub.GetType(zone(), map);
*left_type = *right_type = stub.GetInputType(zone(), map);
}
}
void TypeFeedbackOracle::BinaryType(TypeFeedbackId id,
Handle<Type>* left,
Handle<Type>* right,
Handle<Type>* result,
Type** left,
Type** right,
Type** result,
Maybe<int>* fixed_right_arg,
Handle<AllocationSite>* allocation_site,
Token::Value op) {
@ -275,7 +273,7 @@ void TypeFeedbackOracle::BinaryType(TypeFeedbackId id,
// operations covered by the BinaryOpIC we should always have them.
ASSERT(op < BinaryOpIC::State::FIRST_TOKEN ||
op > BinaryOpIC::State::LAST_TOKEN);
*left = *right = *result = Type::None(isolate_);
*left = *right = *result = Type::None(zone());
*fixed_right_arg = Maybe<int>();
*allocation_site = Handle<AllocationSite>::null();
return;
@ -285,9 +283,9 @@ void TypeFeedbackOracle::BinaryType(TypeFeedbackId id,
BinaryOpIC::State state(code->extended_extra_ic_state());
ASSERT_EQ(op, state.op());
*left = state.GetLeftType(isolate());
*right = state.GetRightType(isolate());
*result = state.GetResultType(isolate());
*left = state.GetLeftType(zone());
*right = state.GetRightType(zone());
*result = state.GetResultType(zone());
*fixed_right_arg = state.fixed_right_arg();
AllocationSite* first_allocation_site = code->FindFirstAllocationSite();
@ -299,13 +297,13 @@ void TypeFeedbackOracle::BinaryType(TypeFeedbackId id,
}
Handle<Type> TypeFeedbackOracle::CountType(TypeFeedbackId id) {
Type* TypeFeedbackOracle::CountType(TypeFeedbackId id) {
Handle<Object> object = GetInfo(id);
if (!object->IsCode()) return Type::None(isolate_);
if (!object->IsCode()) return Type::None(zone());
Handle<Code> code = Handle<Code>::cast(object);
ASSERT_EQ(Code::BINARY_OP_IC, code->kind());
BinaryOpIC::State state(code->extended_extra_ic_state());
return state.GetLeftType(isolate());
return state.GetLeftType(zone());
}
@ -375,7 +373,7 @@ void TypeFeedbackOracle::CollectReceiverTypes(TypeFeedbackId ast_id,
if (FLAG_collect_megamorphic_maps_from_stub_cache &&
code->ic_state() == MEGAMORPHIC) {
types->Reserve(4, zone());
isolate_->stub_cache()->CollectMatchingMaps(
isolate()->stub_cache()->CollectMatchingMaps(
types, name, flags, native_context_, zone());
} else {
CollectReceiverTypes(ast_id, types);
@ -454,7 +452,7 @@ byte TypeFeedbackOracle::ToBooleanTypes(TypeFeedbackId id) {
void TypeFeedbackOracle::BuildDictionary(Handle<Code> code) {
DisallowHeapAllocation no_allocation;
ZoneList<RelocInfo> infos(16, zone());
HandleScope scope(isolate_);
HandleScope scope(isolate());
GetRelocInfos(code, &infos);
CreateDictionary(code, &infos);
ProcessRelocInfos(&infos);

View File

@ -45,7 +45,6 @@ class TypeFeedbackOracle: public ZoneObject {
public:
TypeFeedbackOracle(Handle<Code> code,
Handle<Context> native_context,
Isolate* isolate,
Zone* zone);
bool LoadIsUninitialized(TypeFeedbackId id);
@ -107,22 +106,22 @@ class TypeFeedbackOracle: public ZoneObject {
// Get type information for arithmetic operations and compares.
void BinaryType(TypeFeedbackId id,
Handle<Type>* left,
Handle<Type>* right,
Handle<Type>* result,
Type** left,
Type** right,
Type** result,
Maybe<int>* fixed_right_arg,
Handle<AllocationSite>* allocation_site,
Token::Value operation);
void CompareType(TypeFeedbackId id,
Handle<Type>* left,
Handle<Type>* right,
Handle<Type>* combined);
Type** left,
Type** right,
Type** combined);
Handle<Type> CountType(TypeFeedbackId id);
Type* CountType(TypeFeedbackId id);
Zone* zone() const { return zone_; }
Isolate* isolate() const { return isolate_; }
Isolate* isolate() const { return zone_->isolate(); }
private:
void CollectReceiverTypes(TypeFeedbackId id,
@ -147,7 +146,6 @@ class TypeFeedbackOracle: public ZoneObject {
private:
Handle<Context> native_context_;
Isolate* isolate_;
Zone* zone_;
Handle<UnseededNumberDictionary> dictionary_;

View File

@ -541,7 +541,7 @@ typename TypeImpl<Config>::TypeHandle TypeImpl<Config>::Intersect(
// TODO(rossberg): this does not belong here.
Representation Representation::FromType(Handle<Type> type) {
Representation Representation::FromType(Type* type) {
if (type->Is(Type::None())) return Representation::None();
if (type->Is(Type::Smi())) return Representation::Smi();
if (type->Is(Type::Signed32())) return Representation::Integer32();

View File

@ -496,8 +496,8 @@ struct HeapTypeConfig {
}
};
typedef TypeImpl<ZoneTypeConfig> ZoneType;
typedef TypeImpl<HeapTypeConfig> Type;
typedef TypeImpl<ZoneTypeConfig> Type;
typedef TypeImpl<HeapTypeConfig> HeapType;
// A simple struct to represent a pair of lower/upper type bounds.
@ -550,8 +550,7 @@ struct BoundsImpl {
}
};
typedef BoundsImpl<ZoneTypeConfig> ZoneBounds;
typedef BoundsImpl<HeapTypeConfig> Bounds;
typedef BoundsImpl<ZoneTypeConfig> Bounds;
} } // namespace v8::internal

View File

@ -41,10 +41,9 @@ AstTyper::AstTyper(CompilationInfo* info)
oracle_(
Handle<Code>(info->closure()->shared()->code()),
Handle<Context>(info->closure()->context()->native_context()),
info->isolate(),
info->zone()),
store_(info->zone()) {
InitializeAstVisitor(info->isolate());
InitializeAstVisitor(info->zone());
}
@ -72,7 +71,7 @@ void AstTyper::Run(CompilationInfo* info) {
#ifdef OBJECT_PRINT
static void PrintObserved(Variable* var, Object* value, Handle<Type> type) {
static void PrintObserved(Variable* var, Object* value, Type* type) {
PrintF(" observed %s ", var->IsParameter() ? "param" : "local");
var->name()->Print();
PrintF(" : ");
@ -84,8 +83,8 @@ void AstTyper::Run(CompilationInfo* info) {
Effect AstTyper::ObservedOnStack(Object* value) {
Handle<Type> lower = Type::OfCurrently(handle(value, isolate()), isolate());
return Effect(Bounds(lower, Type::Any(isolate())));
Type* lower = Type::OfCurrently(handle(value, isolate()), zone());
return Effect(Bounds(lower, Type::Any(zone())));
}
@ -233,7 +232,9 @@ void AstTyper::VisitSwitchStatement(SwitchStatement* stmt) {
if (!clause->is_default()) {
Expression* label = clause->label();
// Collect type feedback.
Handle<Type> tag_type, label_type, combined_type;
Type* tag_type;
Type* label_type;
Type* combined_type;
oracle()->CompareType(clause->CompareId(),
&tag_type, &label_type, &combined_type);
NarrowLowerType(stmt->tag(), tag_type);
@ -392,7 +393,7 @@ void AstTyper::VisitConditional(Conditional* expr) {
NarrowType(expr, Bounds::Either(
expr->then_expression()->bounds(),
expr->else_expression()->bounds(), isolate_));
expr->else_expression()->bounds(), zone()));
}
@ -405,13 +406,13 @@ void AstTyper::VisitVariableProxy(VariableProxy* expr) {
void AstTyper::VisitLiteral(Literal* expr) {
Handle<Type> type = Type::Constant(expr->value(), isolate_);
Type* type = Type::Constant(expr->value(), zone());
NarrowType(expr, Bounds(type));
}
void AstTyper::VisitRegExpLiteral(RegExpLiteral* expr) {
NarrowType(expr, Bounds(Type::RegExp(isolate_)));
NarrowType(expr, Bounds(Type::RegExp(zone())));
}
@ -432,7 +433,7 @@ void AstTyper::VisitObjectLiteral(ObjectLiteral* expr) {
RECURSE(Visit(prop->value()));
}
NarrowType(expr, Bounds(Type::Object(isolate_)));
NarrowType(expr, Bounds(Type::Object(zone())));
}
@ -443,7 +444,7 @@ void AstTyper::VisitArrayLiteral(ArrayLiteral* expr) {
RECURSE(Visit(value));
}
NarrowType(expr, Bounds(Type::Array(isolate_)));
NarrowType(expr, Bounds(Type::Array(zone())));
}
@ -495,7 +496,7 @@ void AstTyper::VisitThrow(Throw* expr) {
RECURSE(Visit(expr->exception()));
// TODO(rossberg): is it worth having a non-termination effect?
NarrowType(expr, Bounds(Type::None(isolate_)));
NarrowType(expr, Bounds(Type::None(zone())));
}
@ -587,13 +588,13 @@ void AstTyper::VisitUnaryOperation(UnaryOperation* expr) {
switch (expr->op()) {
case Token::NOT:
case Token::DELETE:
NarrowType(expr, Bounds(Type::Boolean(isolate_)));
NarrowType(expr, Bounds(Type::Boolean(zone())));
break;
case Token::VOID:
NarrowType(expr, Bounds(Type::Undefined(isolate_)));
NarrowType(expr, Bounds(Type::Undefined(zone())));
break;
case Token::TYPEOF:
NarrowType(expr, Bounds(Type::InternalizedString(isolate_)));
NarrowType(expr, Bounds(Type::InternalizedString(zone())));
break;
default:
UNREACHABLE();
@ -611,7 +612,7 @@ void AstTyper::VisitCountOperation(CountOperation* expr) {
RECURSE(Visit(expr->expression()));
NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Number(isolate_)));
NarrowType(expr, Bounds(Type::Smi(zone()), Type::Number(zone())));
VariableProxy* proxy = expr->expression()->AsVariableProxy();
if (proxy != NULL && proxy->var()->IsStackAllocated()) {
@ -622,7 +623,9 @@ void AstTyper::VisitCountOperation(CountOperation* expr) {
void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
// Collect type feedback.
Handle<Type> type, left_type, right_type;
Type* type;
Type* left_type;
Type* right_type;
Maybe<int> fixed_right_arg;
Handle<AllocationSite> allocation_site;
oracle()->BinaryType(expr->BinaryOperationFeedbackId(),
@ -655,20 +658,17 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
store_.Seq(left_effects);
NarrowType(expr, Bounds::Either(
expr->left()->bounds(), expr->right()->bounds(), isolate_));
expr->left()->bounds(), expr->right()->bounds(), zone()));
break;
}
case Token::BIT_OR:
case Token::BIT_AND: {
RECURSE(Visit(expr->left()));
RECURSE(Visit(expr->right()));
Handle<Type> upper = Type::Union(
expr->left()->bounds().upper, expr->right()->bounds().upper,
isolate_);
if (!upper->Is(Type::Signed32()))
upper = Type::Signed32(isolate_);
Handle<Type> lower =
Type::Intersect(Type::Smi(isolate_), upper, isolate_);
Type* upper = Type::Union(
expr->left()->bounds().upper, expr->right()->bounds().upper, zone());
if (!upper->Is(Type::Signed32())) upper = Type::Signed32(zone());
Type* lower = Type::Intersect(Type::Smi(zone()), upper, zone());
NarrowType(expr, Bounds(lower, upper));
break;
}
@ -677,7 +677,7 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
case Token::SAR:
RECURSE(Visit(expr->left()));
RECURSE(Visit(expr->right()));
NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Signed32(isolate_)));
NarrowType(expr, Bounds(Type::Smi(zone()), Type::Signed32(zone())));
break;
case Token::SHR:
RECURSE(Visit(expr->left()));
@ -685,25 +685,25 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
// TODO(rossberg): The upper bound would be Unsigned32, but since there
// is no 'positive Smi' type for the lower bound, we use the smallest
// union of Smi and Unsigned32 as upper bound instead.
NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Number(isolate_)));
NarrowType(expr, Bounds(Type::Smi(zone()), Type::Number(zone())));
break;
case Token::ADD: {
RECURSE(Visit(expr->left()));
RECURSE(Visit(expr->right()));
Bounds l = expr->left()->bounds();
Bounds r = expr->right()->bounds();
Handle<Type> lower =
Type* lower =
l.lower->Is(Type::None()) || r.lower->Is(Type::None()) ?
Type::None(isolate_) :
Type::None(zone()) :
l.lower->Is(Type::String()) || r.lower->Is(Type::String()) ?
Type::String(isolate_) :
Type::String(zone()) :
l.lower->Is(Type::Number()) && r.lower->Is(Type::Number()) ?
Type::Smi(isolate_) : Type::None(isolate_);
Handle<Type> upper =
Type::Smi(zone()) : Type::None(zone());
Type* upper =
l.upper->Is(Type::String()) || r.upper->Is(Type::String()) ?
Type::String(isolate_) :
Type::String(zone()) :
l.upper->Is(Type::Number()) && r.upper->Is(Type::Number()) ?
Type::Number(isolate_) : Type::NumberOrString(isolate_);
Type::Number(zone()) : Type::NumberOrString(zone());
NarrowType(expr, Bounds(lower, upper));
break;
}
@ -713,7 +713,7 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
case Token::MOD:
RECURSE(Visit(expr->left()));
RECURSE(Visit(expr->right()));
NarrowType(expr, Bounds(Type::Smi(isolate_), Type::Number(isolate_)));
NarrowType(expr, Bounds(Type::Smi(zone()), Type::Number(zone())));
break;
default:
UNREACHABLE();
@ -723,7 +723,9 @@ void AstTyper::VisitBinaryOperation(BinaryOperation* expr) {
void AstTyper::VisitCompareOperation(CompareOperation* expr) {
// Collect type feedback.
Handle<Type> left_type, right_type, combined_type;
Type* left_type;
Type* right_type;
Type* combined_type;
oracle()->CompareType(expr->CompareOperationFeedbackId(),
&left_type, &right_type, &combined_type);
NarrowLowerType(expr->left(), left_type);
@ -733,7 +735,7 @@ void AstTyper::VisitCompareOperation(CompareOperation* expr) {
RECURSE(Visit(expr->left()));
RECURSE(Visit(expr->right()));
NarrowType(expr, Bounds(Type::Boolean(isolate_)));
NarrowType(expr, Bounds(Type::Boolean(zone())));
}

View File

@ -70,13 +70,12 @@ class AstTyper: public AstVisitor {
Store store_;
TypeFeedbackOracle* oracle() { return &oracle_; }
Zone* zone() const { return info_->zone(); }
void NarrowType(Expression* e, Bounds b) {
e->set_bounds(Bounds::Both(e->bounds(), b, isolate_));
e->set_bounds(Bounds::Both(e->bounds(), b, zone()));
}
void NarrowLowerType(Expression* e, Handle<Type> t) {
e->set_bounds(Bounds::NarrowLower(e->bounds(), t, isolate_));
void NarrowLowerType(Expression* e, Type* t) {
e->set_bounds(Bounds::NarrowLower(e->bounds(), t, zone()));
}
Effects EnterEffects() {

View File

@ -44,8 +44,8 @@ enum TypeofState { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
class CodeGenerator: public AstVisitor {
public:
explicit CodeGenerator(Isolate* isolate) {
InitializeAstVisitor(isolate);
explicit CodeGenerator(Zone* zone) {
InitializeAstVisitor(zone);
}
static bool MakeCode(CompilationInfo* info);

View File

@ -1068,7 +1068,7 @@ void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) {
#define __ ACCESS_MASM((masm()))
Register StubCompiler::CheckPrototypes(Handle<Type> type,
Register StubCompiler::CheckPrototypes(Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Register holder_reg,
@ -1206,7 +1206,7 @@ void StoreStubCompiler::HandlerFrontendFooter(Handle<Name> name, Label* miss) {
Register LoadStubCompiler::CallbackHandlerFrontend(
Handle<Type> type,
Handle<HeapType> type,
Register object_reg,
Handle<JSObject> holder,
Handle<Name> name,
@ -1900,7 +1900,7 @@ Handle<Code> KeyedStoreStubCompiler::CompileStorePolymorphic(
}
Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<Type> type,
Handle<Code> LoadStubCompiler::CompileLoadNonexistent(Handle<HeapType> type,
Handle<JSObject> last,
Handle<Name> name) {
NonexistentHandlerFrontend(type, last, name);
@ -1983,7 +1983,7 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm,
Handle<Code> LoadStubCompiler::CompileLoadGlobal(
Handle<Type> type,
Handle<HeapType> type,
Handle<GlobalObject> global,
Handle<PropertyCell> cell,
Handle<Name> name,
@ -2042,13 +2042,13 @@ Handle<Code> BaseLoadStoreStubCompiler::CompilePolymorphicIC(
int receiver_count = types->length();
int number_of_handled_maps = 0;
for (int current = 0; current < receiver_count; ++current) {
Handle<Type> type = types->at(current);
Handle<HeapType> type = types->at(current);
Handle<Map> map = IC::TypeToMap(*type, isolate());
if (!map->is_deprecated()) {
number_of_handled_maps++;
// Check map and tail call if there's a match
__ Cmp(map_reg, map);
if (type->Is(Type::Number())) {
if (type->Is(HeapType::Number())) {
ASSERT(!number_case.is_unused());
__ bind(&number_case);
}

View File

@ -41,7 +41,7 @@ TEST(List) {
Isolate* isolate = CcTest::i_isolate();
Zone zone(isolate);
AstNodeFactory<AstNullVisitor> factory(isolate, &zone);
AstNodeFactory<AstNullVisitor> factory(&zone);
AstNode* node = factory.NewEmptyStatement(RelocInfo::kNoPosition);
list->Add(node);
CHECK_EQ(1, list->length());

View File

@ -126,31 +126,29 @@ class Types {
// Testing auxiliaries (breaking the Type abstraction).
struct ZoneRep {
static bool IsTagged(ZoneType* t, int tag) {
static bool IsTagged(Type* t, int tag) {
return !IsBitset(t)
&& reinterpret_cast<intptr_t>(AsTagged(t)->at(0)) == tag;
}
static bool IsBitset(ZoneType* t) {
return reinterpret_cast<intptr_t>(t) & 1;
}
static bool IsClass(ZoneType* t) { return IsTagged(t, 0); }
static bool IsConstant(ZoneType* t) { return IsTagged(t, 1); }
static bool IsUnion(ZoneType* t) { return IsTagged(t, 2); }
static bool IsBitset(Type* t) { return reinterpret_cast<intptr_t>(t) & 1; }
static bool IsClass(Type* t) { return IsTagged(t, 0); }
static bool IsConstant(Type* t) { return IsTagged(t, 1); }
static bool IsUnion(Type* t) { return IsTagged(t, 2); }
static ZoneList<void*>* AsTagged(ZoneType* t) {
static ZoneList<void*>* AsTagged(Type* t) {
return reinterpret_cast<ZoneList<void*>*>(t);
}
static int AsBitset(ZoneType* t) {
static int AsBitset(Type* t) {
return static_cast<int>(reinterpret_cast<intptr_t>(t) >> 1);
}
static Map* AsClass(ZoneType* t) {
static Map* AsClass(Type* t) {
return *reinterpret_cast<Map**>(AsTagged(t)->at(1));
}
static Object* AsConstant(ZoneType* t) {
static Object* AsConstant(Type* t) {
return *reinterpret_cast<Object**>(AsTagged(t)->at(1));
}
static ZoneList<ZoneType*>* AsUnion(ZoneType* t) {
return reinterpret_cast<ZoneList<ZoneType*>*>(AsTagged(t));
static ZoneList<Type*>* AsUnion(Type* t) {
return reinterpret_cast<ZoneList<Type*>*>(AsTagged(t));
}
static Zone* ToRegion(Zone* zone, Isolate* isolate) { return zone; }
@ -158,15 +156,19 @@ struct ZoneRep {
struct HeapRep {
static bool IsBitset(Handle<Type> t) { return t->IsSmi(); }
static bool IsClass(Handle<Type> t) { return t->IsMap(); }
static bool IsConstant(Handle<Type> t) { return t->IsBox(); }
static bool IsUnion(Handle<Type> t) { return t->IsFixedArray(); }
static bool IsBitset(Handle<HeapType> t) { return t->IsSmi(); }
static bool IsClass(Handle<HeapType> t) { return t->IsMap(); }
static bool IsConstant(Handle<HeapType> t) { return t->IsBox(); }
static bool IsUnion(Handle<HeapType> t) { return t->IsFixedArray(); }
static int AsBitset(Handle<Type> t) { return Smi::cast(*t)->value(); }
static Map* AsClass(Handle<Type> t) { return Map::cast(*t); }
static Object* AsConstant(Handle<Type> t) { return Box::cast(*t)->value(); }
static FixedArray* AsUnion(Handle<Type> t) { return FixedArray::cast(*t); }
static int AsBitset(Handle<HeapType> t) { return Smi::cast(*t)->value(); }
static Map* AsClass(Handle<HeapType> t) { return Map::cast(*t); }
static Object* AsConstant(Handle<HeapType> t) {
return Box::cast(*t)->value();
}
static FixedArray* AsUnion(Handle<HeapType> t) {
return FixedArray::cast(*t);
}
static Isolate* ToRegion(Zone* zone, Isolate* isolate) { return isolate; }
};
@ -755,8 +757,8 @@ struct Tests : Rep {
}
};
typedef Tests<ZoneType, ZoneType*, Zone, ZoneRep> ZoneTests;
typedef Tests<Type, Handle<Type>, Isolate, HeapRep> HeapTests;
typedef Tests<Type, Type*, Zone, ZoneRep> ZoneTests;
typedef Tests<HeapType, Handle<HeapType>, Isolate, HeapRep> HeapTests;
TEST(Bitset) {