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

Side by Side Diff: vm/intermediate_language.cc

Issue 10632009: Make the parser agnostic to the TokenStream implementation. This is the first step towards compacti… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
9 #include "vm/flow_graph_compiler.h" 9 #include "vm/flow_graph_compiler.h"
10 #include "vm/locations.h" 10 #include "vm/locations.h"
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 922
923 923
924 void StoreInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) { 924 void StoreInstanceFieldComp::EmitNativeCode(FlowGraphCompiler* compiler) {
925 ASSERT(VerifyValues(instance(), value())); 925 ASSERT(VerifyValues(instance(), value()));
926 Register instance_reg = locs()->in(0).reg(); 926 Register instance_reg = locs()->in(0).reg();
927 Register value_reg = locs()->in(1).reg(); 927 Register value_reg = locs()->in(1).reg();
928 928
929 if (HasICData()) { 929 if (HasICData()) {
930 ASSERT(original() != NULL); 930 ASSERT(original() != NULL);
931 Label* deopt = compiler->AddDeoptStub(original()->cid(), 931 Label* deopt = compiler->AddDeoptStub(original()->cid(),
932 original()->token_index(), 932 original()->token_pos(),
933 original()->try_index(), 933 original()->try_index(),
934 kDeoptInstanceGetterSameTarget, 934 kDeoptInstanceGetterSameTarget,
935 instance_reg, 935 instance_reg,
936 value_reg); 936 value_reg);
937 // Smis do not have instance fields (Smi class is always first). 937 // Smis do not have instance fields (Smi class is always first).
938 Register temp_reg = locs()->temp(0).reg(); 938 Register temp_reg = locs()->temp(0).reg();
939 ASSERT(temp_reg != instance_reg); 939 ASSERT(temp_reg != instance_reg);
940 ASSERT(temp_reg != value_reg); 940 ASSERT(temp_reg != value_reg);
941 ASSERT(ic_data() != NULL); 941 ASSERT(ic_data() != NULL);
942 compiler->EmitClassChecksNoSmi(*ic_data(), instance_reg, temp_reg, deopt); 942 compiler->EmitClassChecksNoSmi(*ic_data(), instance_reg, temp_reg, deopt);
943 } 943 }
944 __ StoreIntoObject(instance_reg, FieldAddress(instance_reg, field().Offset()), 944 __ StoreIntoObject(instance_reg, FieldAddress(instance_reg, field().Offset()),
945 value_reg); 945 value_reg);
946 } 946 }
947 947
948 948
949 LocationSummary* ThrowInstr::MakeLocationSummary() const { 949 LocationSummary* ThrowInstr::MakeLocationSummary() const {
950 const int kNumInputs = 0; 950 const int kNumInputs = 0;
951 const int kNumTemps = 0; 951 const int kNumTemps = 0;
952 return new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 952 return new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
953 } 953 }
954 954
955 955
956 956
957 void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 957 void ThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
958 ASSERT(exception()->IsUse()); 958 ASSERT(exception()->IsUse());
959 compiler->GenerateCallRuntime(cid(), 959 compiler->GenerateCallRuntime(cid(),
960 token_index(), 960 token_pos(),
961 try_index(), 961 try_index(),
962 kThrowRuntimeEntry); 962 kThrowRuntimeEntry);
963 __ int3(); 963 __ int3();
964 } 964 }
965 965
966 966
967 LocationSummary* ReThrowInstr::MakeLocationSummary() const { 967 LocationSummary* ReThrowInstr::MakeLocationSummary() const {
968 const int kNumInputs = 0; 968 const int kNumInputs = 0;
969 const int kNumTemps = 0; 969 const int kNumTemps = 0;
970 return new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall); 970 return new LocationSummary(kNumInputs, kNumTemps, LocationSummary::kCall);
971 } 971 }
972 972
973 973
974 void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { 974 void ReThrowInstr::EmitNativeCode(FlowGraphCompiler* compiler) {
975 ASSERT(exception()->IsUse()); 975 ASSERT(exception()->IsUse());
976 ASSERT(stack_trace()->IsUse()); 976 ASSERT(stack_trace()->IsUse());
977 compiler->GenerateCallRuntime(cid(), 977 compiler->GenerateCallRuntime(cid(),
978 token_index(), 978 token_pos(),
979 try_index(), 979 try_index(),
980 kReThrowRuntimeEntry); 980 kReThrowRuntimeEntry);
981 __ int3(); 981 __ int3();
982 } 982 }
983 983
984 984
985 LocationSummary* BranchInstr::MakeLocationSummary() const { 985 LocationSummary* BranchInstr::MakeLocationSummary() const {
986 if (is_fused_with_comparison()) { 986 if (is_fused_with_comparison()) {
987 return LocationSummary::Make(0, 987 return LocationSummary::Make(0,
988 Location::NoLocation(), 988 Location::NoLocation(),
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 // The arguments to the stub include the closure. The arguments 1111 // The arguments to the stub include the closure. The arguments
1112 // descriptor describes the closure's arguments (and so does not include 1112 // descriptor describes the closure's arguments (and so does not include
1113 // the closure). 1113 // the closure).
1114 Register temp_reg = locs()->temp(0).reg(); 1114 Register temp_reg = locs()->temp(0).reg();
1115 int argument_count = ArgumentCount(); 1115 int argument_count = ArgumentCount();
1116 const Array& arguments_descriptor = 1116 const Array& arguments_descriptor =
1117 CodeGenerator::ArgumentsDescriptor(argument_count - 1, 1117 CodeGenerator::ArgumentsDescriptor(argument_count - 1,
1118 argument_names()); 1118 argument_names());
1119 __ LoadObject(temp_reg, arguments_descriptor); 1119 __ LoadObject(temp_reg, arguments_descriptor);
1120 1120
1121 compiler->GenerateCall(token_index(), 1121 compiler->GenerateCall(token_pos(),
1122 try_index(), 1122 try_index(),
1123 &StubCode::CallClosureFunctionLabel(), 1123 &StubCode::CallClosureFunctionLabel(),
1124 PcDescriptors::kOther); 1124 PcDescriptors::kOther);
1125 __ Drop(argument_count); 1125 __ Drop(argument_count);
1126 } 1126 }
1127 1127
1128 1128
1129 LocationSummary* InstanceCallComp::MakeLocationSummary() const { 1129 LocationSummary* InstanceCallComp::MakeLocationSummary() const {
1130 return MakeCallSummary(); 1130 return MakeCallSummary();
1131 } 1131 }
1132 1132
1133 1133
1134 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1134 void InstanceCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1135 ASSERT(VerifyCallComputation(this)); 1135 ASSERT(VerifyCallComputation(this));
1136 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, 1136 compiler->AddCurrentDescriptor(PcDescriptors::kDeopt,
1137 cid(), 1137 cid(),
1138 token_index(), 1138 token_pos(),
1139 try_index()); 1139 try_index());
1140 compiler->GenerateInstanceCall(cid(), 1140 compiler->GenerateInstanceCall(cid(),
1141 token_index(), 1141 token_pos(),
1142 try_index(), 1142 try_index(),
1143 function_name(), 1143 function_name(),
1144 ArgumentCount(), 1144 ArgumentCount(),
1145 argument_names(), 1145 argument_names(),
1146 checked_argument_count()); 1146 checked_argument_count());
1147 } 1147 }
1148 1148
1149 1149
1150 bool InstanceCallComp::VerifyComputation() { 1150 bool InstanceCallComp::VerifyComputation() {
1151 return VerifyCallComputation(this); 1151 return VerifyCallComputation(this);
1152 } 1152 }
1153 1153
1154 1154
1155 LocationSummary* StaticCallComp::MakeLocationSummary() const { 1155 LocationSummary* StaticCallComp::MakeLocationSummary() const {
1156 return MakeCallSummary(); 1156 return MakeCallSummary();
1157 } 1157 }
1158 1158
1159 1159
1160 void StaticCallComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1160 void StaticCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1161 ASSERT(VerifyCallComputation(this)); 1161 ASSERT(VerifyCallComputation(this));
1162 Label done; 1162 Label done;
1163 if (recognized() == MethodRecognizer::kMathSqrt) { 1163 if (recognized() == MethodRecognizer::kMathSqrt) {
1164 compiler->GenerateInlinedMathSqrt(&done); 1164 compiler->GenerateInlinedMathSqrt(&done);
1165 // Falls through to static call when operand type is not double or smi. 1165 // Falls through to static call when operand type is not double or smi.
1166 } 1166 }
1167 compiler->GenerateStaticCall(cid(), 1167 compiler->GenerateStaticCall(cid(),
1168 token_index(), 1168 token_pos(),
1169 try_index(), 1169 try_index(),
1170 function(), 1170 function(),
1171 ArgumentCount(), 1171 ArgumentCount(),
1172 argument_names()); 1172 argument_names());
1173 __ Bind(&done); 1173 __ Bind(&done);
1174 } 1174 }
1175 1175
1176 1176
1177 LocationSummary* UseVal::MakeLocationSummary() const { 1177 LocationSummary* UseVal::MakeLocationSummary() const {
1178 return NULL; 1178 return NULL;
1179 } 1179 }
1180 1180
1181 1181
1182 void UseVal::EmitNativeCode(FlowGraphCompiler* compiler) { 1182 void UseVal::EmitNativeCode(FlowGraphCompiler* compiler) {
1183 UNIMPLEMENTED(); 1183 UNIMPLEMENTED();
1184 } 1184 }
1185 1185
1186 1186
1187 void AssertAssignableComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1187 void AssertAssignableComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1188 compiler->GenerateAssertAssignable(cid(), 1188 compiler->GenerateAssertAssignable(cid(),
1189 token_index(), 1189 token_pos(),
1190 try_index(), 1190 try_index(),
1191 dst_type(), 1191 dst_type(),
1192 dst_name()); 1192 dst_name());
1193 ASSERT(locs()->in(0).reg() == locs()->out().reg()); 1193 ASSERT(locs()->in(0).reg() == locs()->out().reg());
1194 } 1194 }
1195 1195
1196 1196
1197 LocationSummary* AssertBooleanComp::MakeLocationSummary() const { 1197 LocationSummary* AssertBooleanComp::MakeLocationSummary() const {
1198 return LocationSummary::Make(1, 1198 return LocationSummary::Make(1,
1199 Location::SameAsFirstInput(), 1199 Location::SameAsFirstInput(),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 1272
1273 LocationSummary* AllocateObjectComp::MakeLocationSummary() const { 1273 LocationSummary* AllocateObjectComp::MakeLocationSummary() const {
1274 return MakeCallSummary(); 1274 return MakeCallSummary();
1275 } 1275 }
1276 1276
1277 1277
1278 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1278 void AllocateObjectComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1279 const Class& cls = Class::ZoneHandle(constructor().owner()); 1279 const Class& cls = Class::ZoneHandle(constructor().owner());
1280 const Code& stub = Code::Handle(StubCode::GetAllocationStubForClass(cls)); 1280 const Code& stub = Code::Handle(StubCode::GetAllocationStubForClass(cls));
1281 const ExternalLabel label(cls.ToCString(), stub.EntryPoint()); 1281 const ExternalLabel label(cls.ToCString(), stub.EntryPoint());
1282 compiler->GenerateCall(token_index(), 1282 compiler->GenerateCall(token_pos(),
1283 try_index(), 1283 try_index(),
1284 &label, 1284 &label,
1285 PcDescriptors::kOther); 1285 PcDescriptors::kOther);
1286 __ Drop(arguments().length()); // Discard arguments. 1286 __ Drop(arguments().length()); // Discard arguments.
1287 } 1287 }
1288 1288
1289 1289
1290 LocationSummary* CreateClosureComp::MakeLocationSummary() const { 1290 LocationSummary* CreateClosureComp::MakeLocationSummary() const {
1291 return MakeCallSummary(); 1291 return MakeCallSummary();
1292 } 1292 }
1293 1293
1294 1294
1295 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) { 1295 void CreateClosureComp::EmitNativeCode(FlowGraphCompiler* compiler) {
1296 const Function& closure_function = function(); 1296 const Function& closure_function = function();
1297 const Code& stub = Code::Handle( 1297 const Code& stub = Code::Handle(
1298 StubCode::GetAllocationStubForClosure(closure_function)); 1298 StubCode::GetAllocationStubForClosure(closure_function));
1299 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); 1299 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint());
1300 compiler->GenerateCall(token_index(), try_index(), &label, 1300 compiler->GenerateCall(token_pos(), try_index(), &label,
1301 PcDescriptors::kOther); 1301 PcDescriptors::kOther);
1302 __ Drop(2); // Discard type arguments and receiver. 1302 __ Drop(2); // Discard type arguments and receiver.
1303 } 1303 }
1304 1304
1305 1305
1306 #undef __ 1306 #undef __
1307 1307
1308 } // namespace dart 1308 } // namespace dart
OLDNEW
« no previous file with comments | « vm/intermediate_language.h ('k') | vm/intermediate_language_ia32.cc » ('j') | vm/parser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698