| OLD | NEW |
| 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/globals.h" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/flow_graph_compiler.h" | 8 #include "vm/flow_graph_compiler.h" |
| 9 | 9 |
| 10 #include "vm/ast_printer.h" | 10 #include "vm/ast_printer.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 default: | 163 default: |
| 164 UNIMPLEMENTED(); | 164 UNIMPLEMENTED(); |
| 165 } | 165 } |
| 166 ExternalLabel target_label("InlineCache", label_address); | 166 ExternalLabel target_label("InlineCache", label_address); |
| 167 __ call(&target_label); | 167 __ call(&target_label); |
| 168 AddCurrentDescriptor(PcDescriptors::kIcCall, node_id, token_index); | 168 AddCurrentDescriptor(PcDescriptors::kIcCall, node_id, token_index); |
| 169 __ addq(RSP, Immediate(argument_count * kWordSize)); | 169 __ addq(RSP, Immediate(argument_count * kWordSize)); |
| 170 } | 170 } |
| 171 | 171 |
| 172 | 172 |
| 173 void FlowGraphCompiler::EmitStaticCall(intptr_t token_index, |
| 174 const Function& function, |
| 175 intptr_t argument_count, |
| 176 const Array& argument_names) { |
| 177 const Array& arguments_descriptor = |
| 178 CodeGenerator::ArgumentsDescriptor(argument_count, argument_names); |
| 179 __ LoadObject(RBX, function); |
| 180 __ LoadObject(R10, arguments_descriptor); |
| 181 |
| 182 GenerateCall(token_index, |
| 183 &StubCode::CallStaticFunctionLabel(), |
| 184 PcDescriptors::kFuncCall); |
| 185 __ addq(RSP, Immediate(argument_count * kWordSize)); |
| 186 } |
| 187 |
| 188 |
| 173 void FlowGraphCompiler::VisitCurrentContext(CurrentContextComp* comp) { | 189 void FlowGraphCompiler::VisitCurrentContext(CurrentContextComp* comp) { |
| 174 __ movq(RAX, CTX); | 190 __ movq(RAX, CTX); |
| 175 } | 191 } |
| 176 | 192 |
| 177 | 193 |
| 178 void FlowGraphCompiler::VisitClosureCall(ClosureCallComp* comp) { | 194 void FlowGraphCompiler::VisitClosureCall(ClosureCallComp* comp) { |
| 179 ASSERT(comp->context()->IsTemp()); | 195 ASSERT(comp->context()->IsTemp()); |
| 180 ASSERT(VerifyCallComputation(comp)); | 196 ASSERT(VerifyCallComputation(comp)); |
| 181 // The arguments to the stub include the closure. The arguments | 197 // The arguments to the stub include the closure. The arguments |
| 182 // descriptor describes the closure's arguments (and so does not include | 198 // descriptor describes the closure's arguments (and so does not include |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 __ j(NOT_EQUAL, &load_true, Assembler::kNearJump); | 235 __ j(NOT_EQUAL, &load_true, Assembler::kNearJump); |
| 220 } | 236 } |
| 221 __ LoadObject(RAX, bool_false); | 237 __ LoadObject(RAX, bool_false); |
| 222 __ jmp(&done, Assembler::kNearJump); | 238 __ jmp(&done, Assembler::kNearJump); |
| 223 __ Bind(&load_true); | 239 __ Bind(&load_true); |
| 224 __ LoadObject(RAX, bool_true); | 240 __ LoadObject(RAX, bool_true); |
| 225 __ Bind(&done); | 241 __ Bind(&done); |
| 226 } | 242 } |
| 227 | 243 |
| 228 | 244 |
| 229 | |
| 230 void FlowGraphCompiler::VisitStaticCall(StaticCallComp* comp) { | 245 void FlowGraphCompiler::VisitStaticCall(StaticCallComp* comp) { |
| 231 ASSERT(VerifyCallComputation(comp)); | 246 ASSERT(VerifyCallComputation(comp)); |
| 232 | 247 EmitStaticCall(comp->token_index(), |
| 233 int argument_count = comp->ArgumentCount(); | 248 comp->function(), |
| 234 const Array& arguments_descriptor = | 249 comp->ArgumentCount(), |
| 235 CodeGenerator::ArgumentsDescriptor(argument_count, | 250 comp->argument_names()); |
| 236 comp->argument_names()); | |
| 237 __ LoadObject(RBX, comp->function()); | |
| 238 __ LoadObject(R10, arguments_descriptor); | |
| 239 | |
| 240 GenerateCall(comp->token_index(), | |
| 241 &StubCode::CallStaticFunctionLabel(), | |
| 242 PcDescriptors::kFuncCall); | |
| 243 __ addq(RSP, Immediate(argument_count * kWordSize)); | |
| 244 } | 251 } |
| 245 | 252 |
| 246 | 253 |
| 247 void FlowGraphCompiler::VisitLoadLocal(LoadLocalComp* comp) { | 254 void FlowGraphCompiler::VisitLoadLocal(LoadLocalComp* comp) { |
| 248 if (comp->local().is_captured()) { | 255 if (comp->local().is_captured()) { |
| 249 Bailout("load of context variable"); | 256 Bailout("load of context variable"); |
| 250 } | 257 } |
| 251 __ movq(RAX, Address(RBP, comp->local().index() * kWordSize)); | 258 __ movq(RAX, Address(RBP, comp->local().index() * kWordSize)); |
| 252 } | 259 } |
| 253 | 260 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 __ pushq(RBX); | 329 __ pushq(RBX); |
| 323 __ pushq(RAX); | 330 __ pushq(RAX); |
| 324 EmitInstanceCall(comp->node_id(), comp->token_index(), function_name, 3, | 331 EmitInstanceCall(comp->node_id(), comp->token_index(), function_name, 3, |
| 325 Array::ZoneHandle(), 1); | 332 Array::ZoneHandle(), 1); |
| 326 __ popq(RAX); | 333 __ popq(RAX); |
| 327 } | 334 } |
| 328 | 335 |
| 329 | 336 |
| 330 void FlowGraphCompiler::VisitInstanceSetter(InstanceSetterComp* comp) { | 337 void FlowGraphCompiler::VisitInstanceSetter(InstanceSetterComp* comp) { |
| 331 // Preserve the second argument under the arguments as the result of the | 338 // Preserve the second argument under the arguments as the result of the |
| 332 // computation, then call the getter. | 339 // computation, then call the setter. |
| 333 const String& function_name = | 340 const String& function_name = |
| 334 String::ZoneHandle(Field::SetterSymbol(comp->field_name())); | 341 String::ZoneHandle(Field::SetterSymbol(comp->field_name())); |
| 335 | 342 |
| 336 // Insert a copy of the second (last) argument under the arguments. | 343 // Insert a copy of the second (last) argument under the arguments. |
| 337 __ popq(RAX); // Value. | 344 __ popq(RAX); // Value. |
| 338 __ popq(RBX); // Reciever. | 345 __ popq(RBX); // Receiver. |
| 339 __ pushq(RAX); | 346 __ pushq(RAX); |
| 340 __ pushq(RBX); | 347 __ pushq(RBX); |
| 341 __ pushq(RAX); | 348 __ pushq(RAX); |
| 342 EmitInstanceCall(comp->node_id(), comp->token_index(), function_name, 2, | 349 EmitInstanceCall(comp->node_id(), comp->token_index(), function_name, 2, |
| 343 Array::ZoneHandle(), 1); | 350 Array::ZoneHandle(), 1); |
| 344 __ popq(RAX); | 351 __ popq(RAX); |
| 345 } | 352 } |
| 346 | 353 |
| 347 | 354 |
| 355 void FlowGraphCompiler::VisitStaticSetter(StaticSetterComp* comp) { |
| 356 // Preserve the argument as the result of the computation, |
| 357 // then call the setter. |
| 358 |
| 359 // Duplicate the argument. |
| 360 __ movq(RAX, Address(RSP, 0)); |
| 361 __ pushq(RAX); |
| 362 EmitStaticCall(comp->token_index(), comp->setter_function(), 1, |
| 363 Array::ZoneHandle()); |
| 364 __ popq(RAX); |
| 365 } |
| 366 |
| 367 |
| 348 void FlowGraphCompiler::VisitBooleanNegate(BooleanNegateComp* comp) { | 368 void FlowGraphCompiler::VisitBooleanNegate(BooleanNegateComp* comp) { |
| 349 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); | 369 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); |
| 350 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); | 370 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); |
| 351 Label done; | 371 Label done; |
| 352 LoadValue(RDX, comp->value()); | 372 LoadValue(RDX, comp->value()); |
| 353 __ LoadObject(RAX, bool_true); | 373 __ LoadObject(RAX, bool_true); |
| 354 __ cmpq(RAX, RDX); | 374 __ cmpq(RAX, RDX); |
| 355 __ j(NOT_EQUAL, &done, Assembler::kNearJump); | 375 __ j(NOT_EQUAL, &done, Assembler::kNearJump); |
| 356 __ LoadObject(RAX, bool_false); | 376 __ LoadObject(RAX, bool_false); |
| 357 __ Bind(&done); | 377 __ Bind(&done); |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1197 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) { | 1217 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) { |
| 1198 // We don't compile exception handlers yet. | 1218 // We don't compile exception handlers yet. |
| 1199 code.set_exception_handlers( | 1219 code.set_exception_handlers( |
| 1200 ExceptionHandlers::Handle(ExceptionHandlers::New(0))); | 1220 ExceptionHandlers::Handle(ExceptionHandlers::New(0))); |
| 1201 } | 1221 } |
| 1202 | 1222 |
| 1203 | 1223 |
| 1204 } // namespace dart | 1224 } // namespace dart |
| 1205 | 1225 |
| 1206 #endif // defined TARGET_ARCH_X64 | 1226 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |