| 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 14 matching lines...) Expand all Loading... |
| 25 const char* function_name = parsed_function_.function().ToCString(); | 25 const char* function_name = parsed_function_.function().ToCString(); |
| 26 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 26 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 27 char* chars = reinterpret_cast<char*>( | 27 char* chars = reinterpret_cast<char*>( |
| 28 Isolate::Current()->current_zone()->Allocate(len)); | 28 Isolate::Current()->current_zone()->Allocate(len)); |
| 29 OS::SNPrint(chars, len, kFormat, function_name, reason); | 29 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 30 const Error& error = Error::Handle( | 30 const Error& error = Error::Handle( |
| 31 LanguageError::New(String::Handle(String::New(chars)))); | 31 LanguageError::New(String::Handle(String::New(chars)))); |
| 32 Isolate::Current()->long_jump_base()->Jump(1, error); | 32 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 33 } | 33 } |
| 34 | 34 |
| 35 #define __ assembler_-> |
| 35 | 36 |
| 36 #define __ assembler_-> | 37 |
| 38 void FlowGraphCompiler::GenerateAssertAssignable(intptr_t node_id, |
| 39 intptr_t token_index, |
| 40 const AbstractType& dst_type, |
| 41 const String& dst_name) { |
| 42 Bailout("GenerateAssertAssignable"); |
| 43 } |
| 44 |
| 37 | 45 |
| 38 void FlowGraphCompiler::LoadValue(Value* value) { | 46 void FlowGraphCompiler::LoadValue(Value* value) { |
| 39 if (value->IsConstant()) { | 47 if (value->IsConstant()) { |
| 40 ConstantVal* constant = value->AsConstant(); | 48 ConstantVal* constant = value->AsConstant(); |
| 41 if (constant->instance().IsSmi()) { | 49 if (constant->instance().IsSmi()) { |
| 42 int64_t imm = reinterpret_cast<int64_t>(constant->instance().raw()); | 50 int64_t imm = reinterpret_cast<int64_t>(constant->instance().raw()); |
| 43 __ movq(RAX, Immediate(imm)); | 51 __ movq(RAX, Immediate(imm)); |
| 44 } else { | 52 } else { |
| 45 __ LoadObject(RAX, value->AsConstant()->instance()); | 53 __ LoadObject(RAX, value->AsConstant()->instance()); |
| 46 } | 54 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 if (temp == NULL) return false; | 87 if (temp == NULL) return false; |
| 80 if (i != 0) { | 88 if (i != 0) { |
| 81 if (temp->index() != previous + 1) return false; | 89 if (temp->index() != previous + 1) return false; |
| 82 } | 90 } |
| 83 previous = temp->index(); | 91 previous = temp->index(); |
| 84 } | 92 } |
| 85 return true; | 93 return true; |
| 86 } | 94 } |
| 87 | 95 |
| 88 | 96 |
| 97 // Truee iff. the v2 is above v1 on stack, or one of them is constant. |
| 98 static bool VerifyValues(Value* v1, Value* v2) { |
| 99 if (v1->IsTemp() && v2->IsTemp()) { |
| 100 return (v1->AsTemp()->index() + 1) == v2->AsTemp()->index(); |
| 101 } |
| 102 return true; |
| 103 } |
| 104 |
| 105 |
| 89 void FlowGraphCompiler::EmitInstanceCall(intptr_t node_id, | 106 void FlowGraphCompiler::EmitInstanceCall(intptr_t node_id, |
| 90 intptr_t token_index, | 107 intptr_t token_index, |
| 91 const String& function_name, | 108 const String& function_name, |
| 92 intptr_t argument_count, | 109 intptr_t argument_count, |
| 93 const Array& argument_names, | 110 const Array& argument_names, |
| 94 intptr_t checked_argument_count) { | 111 intptr_t checked_argument_count) { |
| 95 ICData& ic_data = | 112 ICData& ic_data = |
| 96 ICData::ZoneHandle(ICData::New(parsed_function_.function(), | 113 ICData::ZoneHandle(ICData::New(parsed_function_.function(), |
| 97 function_name, | 114 function_name, |
| 98 node_id, | 115 node_id, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 LoadValue(comp->value()); | 186 LoadValue(comp->value()); |
| 170 __ movq(Address(RBP, comp->local().index() * kWordSize), RAX); | 187 __ movq(Address(RBP, comp->local().index() * kWordSize), RAX); |
| 171 } | 188 } |
| 172 | 189 |
| 173 | 190 |
| 174 void FlowGraphCompiler::VisitNativeCall(NativeCallComp* comp) { | 191 void FlowGraphCompiler::VisitNativeCall(NativeCallComp* comp) { |
| 175 Bailout("NativeCallComp"); | 192 Bailout("NativeCallComp"); |
| 176 } | 193 } |
| 177 | 194 |
| 178 | 195 |
| 196 void FlowGraphCompiler::VisitLoadInstanceField(LoadInstanceFieldComp* comp) { |
| 197 LoadValue(comp->instance()); // -> RAX. |
| 198 __ movq(RAX, FieldAddress(RAX, comp->field().Offset())); |
| 199 } |
| 200 |
| 201 |
| 202 void FlowGraphCompiler::VisitStoreInstanceField(StoreInstanceFieldComp* comp) { |
| 203 VerifyValues(comp->instance(), comp->value()); |
| 204 LoadValue(comp->value()); |
| 205 __ movq(R10, RAX); |
| 206 LoadValue(comp->instance()); // -> RAX. |
| 207 __ StoreIntoObject(RAX, FieldAddress(RAX, comp->field().Offset()), R10); |
| 208 } |
| 209 |
| 210 |
| 211 |
| 212 void FlowGraphCompiler::VisitLoadStaticField(LoadStaticFieldComp* comp) { |
| 213 __ LoadObject(RDX, comp->field()); |
| 214 __ movq(RAX, FieldAddress(RDX, Field::value_offset())); |
| 215 } |
| 216 |
| 217 |
| 218 void FlowGraphCompiler::VisitStoreStaticField(StoreStaticFieldComp* comp) { |
| 219 LoadValue(comp->value()); |
| 220 __ LoadObject(RDX, comp->field()); |
| 221 __ StoreIntoObject(RDX, FieldAddress(RDX, Field::value_offset()), RAX); |
| 222 } |
| 223 |
| 224 |
| 179 void FlowGraphCompiler::VisitStoreIndexed(StoreIndexedComp* comp) { | 225 void FlowGraphCompiler::VisitStoreIndexed(StoreIndexedComp* comp) { |
| 180 // Call operator []= but preserve the third argument value under the | 226 // Call operator []= but preserve the third argument value under the |
| 181 // arguments as the result of the computation. | 227 // arguments as the result of the computation. |
| 182 const String& function_name = | 228 const String& function_name = |
| 183 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kASSIGN_INDEX))); | 229 String::ZoneHandle(String::NewSymbol(Token::Str(Token::kASSIGN_INDEX))); |
| 184 | 230 |
| 185 // Insert a copy of the third (last) argument under the arguments. | 231 // Insert a copy of the third (last) argument under the arguments. |
| 186 __ popq(RAX); // Value. | 232 __ popq(RAX); // Value. |
| 187 __ popq(RBX); // Index. | 233 __ popq(RBX); // Index. |
| 188 __ popq(RCX); // Receiver. | 234 __ popq(RCX); // Receiver. |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) { | 466 void FlowGraphCompiler::FinalizeExceptionHandlers(const Code& code) { |
| 421 // We don't compile exception handlers yet. | 467 // We don't compile exception handlers yet. |
| 422 code.set_exception_handlers( | 468 code.set_exception_handlers( |
| 423 ExceptionHandlers::Handle(ExceptionHandlers::New(0))); | 469 ExceptionHandlers::Handle(ExceptionHandlers::New(0))); |
| 424 } | 470 } |
| 425 | 471 |
| 426 | 472 |
| 427 } // namespace dart | 473 } // namespace dart |
| 428 | 474 |
| 429 #endif // defined TARGET_ARCH_X64 | 475 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |