| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1069 // Notice: We must not have a "test rax, ..." instruction after | 1069 // Notice: We must not have a "test rax, ..." instruction after |
| 1070 // the call. It is treated specially by the LoadIC code. | 1070 // the call. It is treated specially by the LoadIC code. |
| 1071 | 1071 |
| 1072 // Drop key left on the stack by IC. | 1072 // Drop key left on the stack by IC. |
| 1073 __ addq(rsp, Immediate(kPointerSize)); | 1073 __ addq(rsp, Immediate(kPointerSize)); |
| 1074 } | 1074 } |
| 1075 DropAndMove(expr->context(), rax); | 1075 DropAndMove(expr->context(), rax); |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 | 1078 |
| 1079 void FastCodeGenerator::EmitCallWithIC(Call* expr, RelocInfo::Mode reloc_info) { | 1079 void FastCodeGenerator::EmitCallWithIC(Call* expr, |
| 1080 Handle<Object> ignored, |
| 1081 RelocInfo::Mode mode) { |
| 1080 // Code common for calls using the IC. | 1082 // Code common for calls using the IC. |
| 1081 ZoneList<Expression*>* args = expr->arguments(); | 1083 ZoneList<Expression*>* args = expr->arguments(); |
| 1082 int arg_count = args->length(); | 1084 int arg_count = args->length(); |
| 1083 for (int i = 0; i < arg_count; i++) { | 1085 for (int i = 0; i < arg_count; i++) { |
| 1084 Visit(args->at(i)); | 1086 Visit(args->at(i)); |
| 1085 ASSERT_EQ(Expression::kValue, args->at(i)->context()); | 1087 ASSERT_EQ(Expression::kValue, args->at(i)->context()); |
| 1086 } | 1088 } |
| 1087 // Record source position for debugger. | 1089 // Record source position for debugger. |
| 1088 SetSourcePosition(expr->position()); | 1090 SetSourcePosition(expr->position()); |
| 1089 // Call the IC initialization code. | 1091 // Call the IC initialization code. |
| 1090 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, | 1092 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, |
| 1091 NOT_IN_LOOP); | 1093 NOT_IN_LOOP); |
| 1092 __ call(ic, reloc_info); | 1094 __ call(ic, mode); |
| 1093 // Restore context register. | 1095 // Restore context register. |
| 1094 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 1096 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 1095 // Discard the function left on TOS. | 1097 // Discard the function left on TOS. |
| 1096 DropAndMove(expr->context(), rax); | 1098 DropAndMove(expr->context(), rax); |
| 1097 } | 1099 } |
| 1098 | 1100 |
| 1099 | 1101 |
| 1100 void FastCodeGenerator::EmitCallWithStub(Call* expr) { | 1102 void FastCodeGenerator::EmitCallWithStub(Call* expr) { |
| 1101 // Code common for calls using the call stub. | 1103 // Code common for calls using the call stub. |
| 1102 ZoneList<Expression*>* args = expr->arguments(); | 1104 ZoneList<Expression*>* args = expr->arguments(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1121 Variable* var = fun->AsVariableProxy()->AsVariable(); | 1123 Variable* var = fun->AsVariableProxy()->AsVariable(); |
| 1122 | 1124 |
| 1123 if (var != NULL && var->is_possibly_eval()) { | 1125 if (var != NULL && var->is_possibly_eval()) { |
| 1124 // Call to the identifier 'eval'. | 1126 // Call to the identifier 'eval'. |
| 1125 UNREACHABLE(); | 1127 UNREACHABLE(); |
| 1126 } else if (var != NULL && !var->is_this() && var->is_global()) { | 1128 } else if (var != NULL && !var->is_this() && var->is_global()) { |
| 1127 // Call to a global variable. | 1129 // Call to a global variable. |
| 1128 __ Push(var->name()); | 1130 __ Push(var->name()); |
| 1129 // Push global object as receiver for the call IC lookup. | 1131 // Push global object as receiver for the call IC lookup. |
| 1130 __ push(CodeGenerator::GlobalObject()); | 1132 __ push(CodeGenerator::GlobalObject()); |
| 1131 EmitCallWithIC(expr, RelocInfo::CODE_TARGET_CONTEXT); | 1133 EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT); |
| 1132 } else if (var != NULL && var->slot() != NULL && | 1134 } else if (var != NULL && var->slot() != NULL && |
| 1133 var->slot()->type() == Slot::LOOKUP) { | 1135 var->slot()->type() == Slot::LOOKUP) { |
| 1134 // Call to a lookup slot. | 1136 // Call to a lookup slot. |
| 1135 UNREACHABLE(); | 1137 UNREACHABLE(); |
| 1136 } else if (fun->AsProperty() != NULL) { | 1138 } else if (fun->AsProperty() != NULL) { |
| 1137 // Call to an object property. | 1139 // Call to an object property. |
| 1138 Property* prop = fun->AsProperty(); | 1140 Property* prop = fun->AsProperty(); |
| 1139 Literal* key = prop->key()->AsLiteral(); | 1141 Literal* key = prop->key()->AsLiteral(); |
| 1140 if (key != NULL && key->handle()->IsSymbol()) { | 1142 if (key != NULL && key->handle()->IsSymbol()) { |
| 1141 // Call to a named property, use call IC. | 1143 // Call to a named property, use call IC. |
| 1142 __ Push(key->handle()); | 1144 __ Push(key->handle()); |
| 1143 Visit(prop->obj()); | 1145 Visit(prop->obj()); |
| 1144 EmitCallWithIC(expr, RelocInfo::CODE_TARGET); | 1146 EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET); |
| 1145 } else { | 1147 } else { |
| 1146 // Call to a keyed property, use keyed load IC followed by function | 1148 // Call to a keyed property, use keyed load IC followed by function |
| 1147 // call. | 1149 // call. |
| 1148 Visit(prop->obj()); | 1150 Visit(prop->obj()); |
| 1149 Visit(prop->key()); | 1151 Visit(prop->key()); |
| 1150 // Record source code position for IC call. | 1152 // Record source code position for IC call. |
| 1151 SetSourcePosition(prop->position()); | 1153 SetSourcePosition(prop->position()); |
| 1152 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); | 1154 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); |
| 1153 __ call(ic, RelocInfo::CODE_TARGET); | 1155 __ call(ic, RelocInfo::CODE_TARGET); |
| 1154 // By emitting a nop we make sure that we do not have a "test rax,..." | 1156 // By emitting a nop we make sure that we do not have a "test rax,..." |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1723 | 1725 |
| 1724 void FastCodeGenerator::ThrowException() { | 1726 void FastCodeGenerator::ThrowException() { |
| 1725 __ push(result_register()); | 1727 __ push(result_register()); |
| 1726 __ CallRuntime(Runtime::kThrow, 1); | 1728 __ CallRuntime(Runtime::kThrow, 1); |
| 1727 } | 1729 } |
| 1728 | 1730 |
| 1729 #undef __ | 1731 #undef __ |
| 1730 | 1732 |
| 1731 | 1733 |
| 1732 } } // namespace v8::internal | 1734 } } // namespace v8::internal |
| OLD | NEW |