Slightly generalize AddCheckConstantFunction.

This is needed for crankshafted accessors, which are syntactically not a Call.

Review URL: https://chromiumcodereview.appspot.com/10702109

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11997 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 482a0e31
...@@ -1584,7 +1584,12 @@ class Call: public Expression { ...@@ -1584,7 +1584,12 @@ class Call: public Expression {
virtual bool IsMonomorphic() { return is_monomorphic_; } virtual bool IsMonomorphic() { return is_monomorphic_; }
CheckType check_type() const { return check_type_; } CheckType check_type() const { return check_type_; }
Handle<JSFunction> target() { return target_; } Handle<JSFunction> target() { return target_; }
// A cache for the holder, set as a side effect of computing the target of the
// call. Note that it contains the null handle when the receiver is the same
// as the holder!
Handle<JSObject> holder() { return holder_; } Handle<JSObject> holder() { return holder_; }
Handle<JSGlobalPropertyCell> cell() { return cell_; } Handle<JSGlobalPropertyCell> cell() { return cell_; }
bool ComputeTarget(Handle<Map> type, Handle<String> name); bool ComputeTarget(Handle<Map> type, Handle<String> name);
......
...@@ -6284,7 +6284,7 @@ void HGraphBuilder::VisitProperty(Property* expr) { ...@@ -6284,7 +6284,7 @@ void HGraphBuilder::VisitProperty(Property* expr) {
} }
void HGraphBuilder::AddCheckConstantFunction(Call* expr, void HGraphBuilder::AddCheckConstantFunction(Handle<JSObject> holder,
HValue* receiver, HValue* receiver,
Handle<Map> receiver_map, Handle<Map> receiver_map,
bool smi_and_map_check) { bool smi_and_map_check) {
...@@ -6296,10 +6296,9 @@ void HGraphBuilder::AddCheckConstantFunction(Call* expr, ...@@ -6296,10 +6296,9 @@ void HGraphBuilder::AddCheckConstantFunction(Call* expr,
AddInstruction(HCheckMaps::NewWithTransitions(receiver, receiver_map, AddInstruction(HCheckMaps::NewWithTransitions(receiver, receiver_map,
zone())); zone()));
} }
if (!expr->holder().is_null()) { if (!holder.is_null()) {
AddInstruction(new(zone()) HCheckPrototypeMaps( AddInstruction(new(zone()) HCheckPrototypeMaps(
Handle<JSObject>(JSObject::cast(receiver_map->prototype())), Handle<JSObject>(JSObject::cast(receiver_map->prototype())), holder));
expr->holder()));
} }
} }
...@@ -6382,7 +6381,7 @@ void HGraphBuilder::HandlePolymorphicCallNamed(Call* expr, ...@@ -6382,7 +6381,7 @@ void HGraphBuilder::HandlePolymorphicCallNamed(Call* expr,
set_current_block(if_true); set_current_block(if_true);
expr->ComputeTarget(map, name); expr->ComputeTarget(map, name);
AddCheckConstantFunction(expr, receiver, map, false); AddCheckConstantFunction(expr->holder(), receiver, map, false);
if (FLAG_trace_inlining && FLAG_polymorphic_inlining) { if (FLAG_trace_inlining && FLAG_polymorphic_inlining) {
Handle<JSFunction> caller = info()->closure(); Handle<JSFunction> caller = info()->closure();
SmartArrayPointer<char> caller_name = SmartArrayPointer<char> caller_name =
...@@ -6889,7 +6888,7 @@ bool HGraphBuilder::TryInlineBuiltinMethodCall(Call* expr, ...@@ -6889,7 +6888,7 @@ bool HGraphBuilder::TryInlineBuiltinMethodCall(Call* expr,
case kMathCos: case kMathCos:
case kMathTan: case kMathTan:
if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) { if (argument_count == 2 && check_type == RECEIVER_MAP_CHECK) {
AddCheckConstantFunction(expr, receiver, receiver_map, true); AddCheckConstantFunction(expr->holder(), receiver, receiver_map, true);
HValue* argument = Pop(); HValue* argument = Pop();
HValue* context = environment()->LookupContext(); HValue* context = environment()->LookupContext();
Drop(1); // Receiver. Drop(1); // Receiver.
...@@ -6902,7 +6901,7 @@ bool HGraphBuilder::TryInlineBuiltinMethodCall(Call* expr, ...@@ -6902,7 +6901,7 @@ bool HGraphBuilder::TryInlineBuiltinMethodCall(Call* expr,
break; break;
case kMathPow: case kMathPow:
if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) {
AddCheckConstantFunction(expr, receiver, receiver_map, true); AddCheckConstantFunction(expr->holder(), receiver, receiver_map, true);
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
Pop(); // Pop receiver. Pop(); // Pop receiver.
...@@ -6944,7 +6943,7 @@ bool HGraphBuilder::TryInlineBuiltinMethodCall(Call* expr, ...@@ -6944,7 +6943,7 @@ bool HGraphBuilder::TryInlineBuiltinMethodCall(Call* expr,
break; break;
case kMathRandom: case kMathRandom:
if (argument_count == 1 && check_type == RECEIVER_MAP_CHECK) { if (argument_count == 1 && check_type == RECEIVER_MAP_CHECK) {
AddCheckConstantFunction(expr, receiver, receiver_map, true); AddCheckConstantFunction(expr->holder(), receiver, receiver_map, true);
Drop(1); // Receiver. Drop(1); // Receiver.
HValue* context = environment()->LookupContext(); HValue* context = environment()->LookupContext();
HGlobalObject* global_object = new(zone()) HGlobalObject(context); HGlobalObject* global_object = new(zone()) HGlobalObject(context);
...@@ -6957,7 +6956,7 @@ bool HGraphBuilder::TryInlineBuiltinMethodCall(Call* expr, ...@@ -6957,7 +6956,7 @@ bool HGraphBuilder::TryInlineBuiltinMethodCall(Call* expr,
case kMathMax: case kMathMax:
case kMathMin: case kMathMin:
if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) { if (argument_count == 3 && check_type == RECEIVER_MAP_CHECK) {
AddCheckConstantFunction(expr, receiver, receiver_map, true); AddCheckConstantFunction(expr->holder(), receiver, receiver_map, true);
HValue* right = Pop(); HValue* right = Pop();
HValue* left = Pop(); HValue* left = Pop();
Pop(); // Pop receiver. Pop(); // Pop receiver.
...@@ -7073,7 +7072,7 @@ bool HGraphBuilder::TryCallApply(Call* expr) { ...@@ -7073,7 +7072,7 @@ bool HGraphBuilder::TryCallApply(Call* expr) {
VisitForValue(prop->obj()); VisitForValue(prop->obj());
if (HasStackOverflow() || current_block() == NULL) return true; if (HasStackOverflow() || current_block() == NULL) return true;
HValue* function = Top(); HValue* function = Top();
AddCheckConstantFunction(expr, function, function_map, true); AddCheckConstantFunction(expr->holder(), function, function_map, true);
Drop(1); Drop(1);
VisitForValue(args->at(0)); VisitForValue(args->at(0));
...@@ -7192,7 +7191,7 @@ void HGraphBuilder::VisitCall(Call* expr) { ...@@ -7192,7 +7191,7 @@ void HGraphBuilder::VisitCall(Call* expr) {
call = PreProcessCall( call = PreProcessCall(
new(zone()) HCallNamed(context, name, argument_count)); new(zone()) HCallNamed(context, name, argument_count));
} else { } else {
AddCheckConstantFunction(expr, receiver, receiver_map, true); AddCheckConstantFunction(expr->holder(), receiver, receiver_map, true);
if (TryInlineCall(expr)) return; if (TryInlineCall(expr)) return;
call = PreProcessCall( call = PreProcessCall(
......
...@@ -1165,7 +1165,7 @@ class HGraphBuilder: public AstVisitor { ...@@ -1165,7 +1165,7 @@ class HGraphBuilder: public AstVisitor {
HInstruction* BuildThisFunction(); HInstruction* BuildThisFunction();
void AddCheckConstantFunction(Call* expr, void AddCheckConstantFunction(Handle<JSObject> holder,
HValue* receiver, HValue* receiver,
Handle<Map> receiver_map, Handle<Map> receiver_map,
bool smi_and_map_check); bool smi_and_map_check);
......
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