Commit bf06fbdb authored by whesse@chromium.org's avatar whesse@chromium.org

Recommit "First step in letting Crankshaft inline functions with a different context.""

This reverts r7810, thus recommitting 7807.

BUG=
TEST=

Review URL: http://codereview.chromium.org/6963009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7851 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 79e76dbd
...@@ -1015,6 +1015,8 @@ LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) { ...@@ -1015,6 +1015,8 @@ LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) {
outer); outer);
int argument_index = 0; int argument_index = 0;
for (int i = 0; i < value_count; ++i) { for (int i = 0; i < value_count; ++i) {
if (hydrogen_env->is_special_index(i)) continue;
HValue* value = hydrogen_env->values()->at(i); HValue* value = hydrogen_env->values()->at(i);
LOperand* op = NULL; LOperand* op = NULL;
if (value->IsArgumentsObject()) { if (value->IsArgumentsObject()) {
......
...@@ -3326,7 +3326,7 @@ class HLoadKeyedSpecializedArrayElement: public HBinaryOperation { ...@@ -3326,7 +3326,7 @@ class HLoadKeyedSpecializedArrayElement: public HBinaryOperation {
class HLoadKeyedGeneric: public HTemplateInstruction<3> { class HLoadKeyedGeneric: public HTemplateInstruction<3> {
public: public:
HLoadKeyedGeneric(HContext* context, HValue* obj, HValue* key) { HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) {
set_representation(Representation::Tagged()); set_representation(Representation::Tagged());
SetOperandAt(0, obj); SetOperandAt(0, obj);
SetOperandAt(1, key); SetOperandAt(1, key);
......
This diff is collapsed.
...@@ -322,6 +322,7 @@ class HEnvironment: public ZoneObject { ...@@ -322,6 +322,7 @@ class HEnvironment: public ZoneObject {
return &assigned_variables_; return &assigned_variables_;
} }
int parameter_count() const { return parameter_count_; } int parameter_count() const { return parameter_count_; }
int specials_count() const { return specials_count_; }
int local_count() const { return local_count_; } int local_count() const { return local_count_; }
HEnvironment* outer() const { return outer_; } HEnvironment* outer() const { return outer_; }
int pop_count() const { return pop_count_; } int pop_count() const { return pop_count_; }
...@@ -331,6 +332,9 @@ class HEnvironment: public ZoneObject { ...@@ -331,6 +332,9 @@ class HEnvironment: public ZoneObject {
void set_ast_id(int id) { ast_id_ = id; } void set_ast_id(int id) { ast_id_ = id; }
int length() const { return values_.length(); } int length() const { return values_.length(); }
bool is_special_index(int i) const {
return i >= parameter_count() && i < parameter_count() + specials_count();
}
void Bind(Variable* variable, HValue* value) { void Bind(Variable* variable, HValue* value) {
Bind(IndexFor(variable), value); Bind(IndexFor(variable), value);
...@@ -338,6 +342,10 @@ class HEnvironment: public ZoneObject { ...@@ -338,6 +342,10 @@ class HEnvironment: public ZoneObject {
void Bind(int index, HValue* value); void Bind(int index, HValue* value);
void BindContext(HValue* value) {
Bind(parameter_count(), value);
}
HValue* Lookup(Variable* variable) const { HValue* Lookup(Variable* variable) const {
return Lookup(IndexFor(variable)); return Lookup(IndexFor(variable));
} }
...@@ -348,6 +356,11 @@ class HEnvironment: public ZoneObject { ...@@ -348,6 +356,11 @@ class HEnvironment: public ZoneObject {
return result; return result;
} }
HValue* LookupContext() const {
// Return first special.
return Lookup(parameter_count());
}
void Push(HValue* value) { void Push(HValue* value) {
ASSERT(value != NULL); ASSERT(value != NULL);
++push_count_; ++push_count_;
...@@ -368,6 +381,8 @@ class HEnvironment: public ZoneObject { ...@@ -368,6 +381,8 @@ class HEnvironment: public ZoneObject {
HValue* Top() const { return ExpressionStackAt(0); } HValue* Top() const { return ExpressionStackAt(0); }
bool ExpressionStackIsEmpty() const;
HValue* ExpressionStackAt(int index_from_top) const { HValue* ExpressionStackAt(int index_from_top) const {
int index = length() - index_from_top - 1; int index = length() - index_from_top - 1;
ASSERT(HasExpressionAt(index)); ASSERT(HasExpressionAt(index));
...@@ -412,8 +427,6 @@ class HEnvironment: public ZoneObject { ...@@ -412,8 +427,6 @@ class HEnvironment: public ZoneObject {
// True if index is included in the expression stack part of the environment. // True if index is included in the expression stack part of the environment.
bool HasExpressionAt(int index) const; bool HasExpressionAt(int index) const;
bool ExpressionStackIsEmpty() const;
void Initialize(int parameter_count, int local_count, int stack_height); void Initialize(int parameter_count, int local_count, int stack_height);
void Initialize(const HEnvironment* other); void Initialize(const HEnvironment* other);
...@@ -423,15 +436,18 @@ class HEnvironment: public ZoneObject { ...@@ -423,15 +436,18 @@ class HEnvironment: public ZoneObject {
int IndexFor(Variable* variable) const { int IndexFor(Variable* variable) const {
Slot* slot = variable->AsSlot(); Slot* slot = variable->AsSlot();
ASSERT(slot != NULL && slot->IsStackAllocated()); ASSERT(slot != NULL && slot->IsStackAllocated());
int shift = (slot->type() == Slot::PARAMETER) ? 1 : parameter_count_; int shift = (slot->type() == Slot::PARAMETER)
? 1
: parameter_count_ + specials_count_;
return slot->index() + shift; return slot->index() + shift;
} }
Handle<JSFunction> closure_; Handle<JSFunction> closure_;
// Value array [parameters] [locals] [temporaries]. // Value array [parameters] [specials] [locals] [temporaries].
ZoneList<HValue*> values_; ZoneList<HValue*> values_;
ZoneList<int> assigned_variables_; ZoneList<int> assigned_variables_;
int parameter_count_; int parameter_count_;
int specials_count_;
int local_count_; int local_count_;
HEnvironment* outer_; HEnvironment* outer_;
int pop_count_; int pop_count_;
......
...@@ -1010,6 +1010,8 @@ LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) { ...@@ -1010,6 +1010,8 @@ LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) {
outer); outer);
int argument_index = 0; int argument_index = 0;
for (int i = 0; i < value_count; ++i) { for (int i = 0; i < value_count; ++i) {
if (hydrogen_env->is_special_index(i)) continue;
HValue* value = hydrogen_env->values()->at(i); HValue* value = hydrogen_env->values()->at(i);
LOperand* op = NULL; LOperand* op = NULL;
if (value->IsArgumentsObject()) { if (value->IsArgumentsObject()) {
......
...@@ -1010,6 +1010,8 @@ LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) { ...@@ -1010,6 +1010,8 @@ LEnvironment* LChunkBuilder::CreateEnvironment(HEnvironment* hydrogen_env) {
outer); outer);
int argument_index = 0; int argument_index = 0;
for (int i = 0; i < value_count; ++i) { for (int i = 0; i < value_count; ++i) {
if (hydrogen_env->is_special_index(i)) continue;
HValue* value = hydrogen_env->values()->at(i); HValue* value = hydrogen_env->values()->at(i);
LOperand* op = NULL; LOperand* op = NULL;
if (value->IsArgumentsObject()) { if (value->IsArgumentsObject()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment