| OLD | NEW |
| 1 // Copyright (c) 2014, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 #ifdef FLETCH_ENABLE_LIVE_CODING | 5 #ifdef DARTINO_ENABLE_LIVE_CODING |
| 6 | 6 |
| 7 #include "src/vm/session.h" | 7 #include "src/vm/session.h" |
| 8 | 8 |
| 9 #include "src/shared/bytecodes.h" | 9 #include "src/shared/bytecodes.h" |
| 10 #include "src/shared/connection.h" | 10 #include "src/shared/connection.h" |
| 11 #include "src/shared/flags.h" | 11 #include "src/shared/flags.h" |
| 12 #include "src/shared/platform.h" | 12 #include "src/shared/platform.h" |
| 13 #include "src/shared/version.h" | 13 #include "src/shared/version.h" |
| 14 | 14 |
| 15 #include "src/vm/frame.h" | 15 #include "src/vm/frame.h" |
| 16 #include "src/vm/heap_validator.h" | 16 #include "src/vm/heap_validator.h" |
| 17 #include "src/vm/native_interpreter.h" | 17 #include "src/vm/native_interpreter.h" |
| 18 #include "src/vm/links.h" | 18 #include "src/vm/links.h" |
| 19 #include "src/vm/object_map.h" | 19 #include "src/vm/object_map.h" |
| 20 #include "src/vm/process.h" | 20 #include "src/vm/process.h" |
| 21 #include "src/vm/scheduler.h" | 21 #include "src/vm/scheduler.h" |
| 22 #include "src/vm/snapshot.h" | 22 #include "src/vm/snapshot.h" |
| 23 #include "src/vm/thread.h" | 23 #include "src/vm/thread.h" |
| 24 | 24 |
| 25 #define GC_AND_RETRY_ON_ALLOCATION_FAILURE(var, exp) \ | 25 #define GC_AND_RETRY_ON_ALLOCATION_FAILURE(var, exp) \ |
| 26 Object* var = (exp); \ | 26 Object* var = (exp); \ |
| 27 ASSERT(execution_paused_); \ | 27 ASSERT(execution_paused_); \ |
| 28 if (var->IsRetryAfterGCFailure()) { \ | 28 if (var->IsRetryAfterGCFailure()) { \ |
| 29 program()->CollectGarbage(); \ | 29 program()->CollectGarbage(); \ |
| 30 var = (exp); \ | 30 var = (exp); \ |
| 31 ASSERT(!var->IsFailure()); \ | 31 ASSERT(!var->IsFailure()); \ |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace fletch { | 34 namespace dartino { |
| 35 | 35 |
| 36 class ConnectionPrintInterceptor : public PrintInterceptor { | 36 class ConnectionPrintInterceptor : public PrintInterceptor { |
| 37 public: | 37 public: |
| 38 explicit ConnectionPrintInterceptor(Connection* connection) | 38 explicit ConnectionPrintInterceptor(Connection* connection) |
| 39 : connection_(connection) {} | 39 : connection_(connection) {} |
| 40 virtual ~ConnectionPrintInterceptor() {} | 40 virtual ~ConnectionPrintInterceptor() {} |
| 41 | 41 |
| 42 virtual void Out(char* message) { | 42 virtual void Out(char* message) { |
| 43 WriteBuffer buffer; | 43 WriteBuffer buffer; |
| 44 buffer.WriteString(message); | 44 buffer.WriteString(message); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 method_map_id_(-1), | 101 method_map_id_(-1), |
| 102 class_map_id_(-1), | 102 class_map_id_(-1), |
| 103 fibers_map_id_(-1), | 103 fibers_map_id_(-1), |
| 104 stack_(0), | 104 stack_(0), |
| 105 first_change_(NULL), | 105 first_change_(NULL), |
| 106 last_change_(NULL), | 106 last_change_(NULL), |
| 107 has_program_update_error_(false), | 107 has_program_update_error_(false), |
| 108 program_update_error_(NULL), | 108 program_update_error_(NULL), |
| 109 main_thread_monitor_(Platform::CreateMonitor()), | 109 main_thread_monitor_(Platform::CreateMonitor()), |
| 110 main_thread_resume_kind_(kUnknown) { | 110 main_thread_resume_kind_(kUnknown) { |
| 111 #ifdef FLETCH_ENABLE_PRINT_INTERCEPTORS | 111 #ifdef DARTINO_ENABLE_PRINT_INTERCEPTORS |
| 112 ConnectionPrintInterceptor* interceptor = | 112 ConnectionPrintInterceptor* interceptor = |
| 113 new ConnectionPrintInterceptor(connection_); | 113 new ConnectionPrintInterceptor(connection_); |
| 114 Print::RegisterPrintInterceptor(interceptor); | 114 Print::RegisterPrintInterceptor(interceptor); |
| 115 #endif // FLETCH_ENABLE_PRINT_INTERCEPTORS | 115 #endif // DARTINO_ENABLE_PRINT_INTERCEPTORS |
| 116 } | 116 } |
| 117 | 117 |
| 118 Session::~Session() { | 118 Session::~Session() { |
| 119 #ifdef FLETCH_ENABLE_PRINT_INTERCEPTORS | 119 #ifdef DARTINO_ENABLE_PRINT_INTERCEPTORS |
| 120 Print::UnregisterPrintInterceptors(); | 120 Print::UnregisterPrintInterceptors(); |
| 121 #endif // FLETCH_ENABLE_PRINT_INTERCEPTORS | 121 #endif // DARTINO_ENABLE_PRINT_INTERCEPTORS |
| 122 | 122 |
| 123 delete connection_; | 123 delete connection_; |
| 124 delete program_; | 124 delete program_; |
| 125 delete main_thread_monitor_; | 125 delete main_thread_monitor_; |
| 126 for (int i = 0; i < maps_.length(); ++i) delete maps_[i]; | 126 for (int i = 0; i < maps_.length(); ++i) delete maps_[i]; |
| 127 maps_.Delete(); | 127 maps_.Delete(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void Session::Initialize() { | 130 void Session::Initialize() { |
| 131 program_ = new Program(Program::kBuiltViaSession); | 131 program_ = new Program(Program::kBuiltViaSession); |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 } else if (name == Names::kPort) { | 1200 } else if (name == Names::kPort) { |
| 1201 klass = program()->port_class(); | 1201 klass = program()->port_class(); |
| 1202 } else if (name == Names::kProcess) { | 1202 } else if (name == Names::kProcess) { |
| 1203 klass = program()->process_class(); | 1203 klass = program()->process_class(); |
| 1204 } else if (name == Names::kProcessDeath) { | 1204 } else if (name == Names::kProcessDeath) { |
| 1205 klass = program()->process_death_class(); | 1205 klass = program()->process_death_class(); |
| 1206 } else if (name == Names::kForeignMemory) { | 1206 } else if (name == Names::kForeignMemory) { |
| 1207 klass = program()->foreign_memory_class(); | 1207 klass = program()->foreign_memory_class(); |
| 1208 } else if (name == Names::kStackOverflowError) { | 1208 } else if (name == Names::kStackOverflowError) { |
| 1209 klass = program()->stack_overflow_error_class(); | 1209 klass = program()->stack_overflow_error_class(); |
| 1210 } else if (name == Names::kFletchNoSuchMethodError) { | 1210 } else if (name == Names::kDartinoNoSuchMethodError) { |
| 1211 klass = program()->no_such_method_error_class(); | 1211 klass = program()->no_such_method_error_class(); |
| 1212 } else { | 1212 } else { |
| 1213 UNREACHABLE(); | 1213 UNREACHABLE(); |
| 1214 } | 1214 } |
| 1215 | 1215 |
| 1216 ASSERT(klass->instance_format().type() != InstanceFormat::INSTANCE_TYPE || | 1216 ASSERT(klass->instance_format().type() != InstanceFormat::INSTANCE_TYPE || |
| 1217 klass->NumberOfInstanceFields() == fields); | 1217 klass->NumberOfInstanceFields() == fields); |
| 1218 | 1218 |
| 1219 Push(klass); | 1219 Push(klass); |
| 1220 } | 1220 } |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 Frame frame(stack); | 1668 Frame frame(stack); |
| 1669 for (int i = 0; i <= frame_index; i++) frame.MovePrevious(); | 1669 for (int i = 0; i <= frame_index; i++) frame.MovePrevious(); |
| 1670 | 1670 |
| 1671 // Reset the return address to the entry function. | 1671 // Reset the return address to the entry function. |
| 1672 frame.SetReturnAddress(reinterpret_cast<void*>(InterpreterEntry)); | 1672 frame.SetReturnAddress(reinterpret_cast<void*>(InterpreterEntry)); |
| 1673 | 1673 |
| 1674 // Finally resize the stack to the next frame pointer. | 1674 // Finally resize the stack to the next frame pointer. |
| 1675 stack->SetTopFromPointer(frame.FramePointer()); | 1675 stack->SetTopFromPointer(frame.FramePointer()); |
| 1676 } | 1676 } |
| 1677 | 1677 |
| 1678 } // namespace fletch | 1678 } // namespace dartino |
| 1679 | 1679 |
| 1680 #endif // FLETCH_ENABLE_LIVE_CODING | 1680 #endif // DARTINO_ENABLE_LIVE_CODING |
| OLD | NEW |