| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 104       method_map_id_(-1), | 104       method_map_id_(-1), | 
| 105       class_map_id_(-1), | 105       class_map_id_(-1), | 
| 106       fibers_map_id_(-1), | 106       fibers_map_id_(-1), | 
| 107       stack_(0), | 107       stack_(0), | 
| 108       first_change_(NULL), | 108       first_change_(NULL), | 
| 109       last_change_(NULL), | 109       last_change_(NULL), | 
| 110       has_program_update_error_(false), | 110       has_program_update_error_(false), | 
| 111       program_update_error_(NULL), | 111       program_update_error_(NULL), | 
| 112       main_thread_monitor_(Platform::CreateMonitor()), | 112       main_thread_monitor_(Platform::CreateMonitor()), | 
| 113       main_thread_resume_kind_(kUnknown) { | 113       main_thread_resume_kind_(kUnknown) { | 
| 114 #ifdef FLETCH_ENABLE_PRINT_INTERCEPTORS | 114 #ifdef DARTINO_ENABLE_PRINT_INTERCEPTORS | 
| 115   ConnectionPrintInterceptor* interceptor = | 115   ConnectionPrintInterceptor* interceptor = | 
| 116       new ConnectionPrintInterceptor(connection_); | 116       new ConnectionPrintInterceptor(connection_); | 
| 117   Print::RegisterPrintInterceptor(interceptor); | 117   Print::RegisterPrintInterceptor(interceptor); | 
| 118 #endif  // FLETCH_ENABLE_PRINT_INTERCEPTORS | 118 #endif  // DARTINO_ENABLE_PRINT_INTERCEPTORS | 
| 119 } | 119 } | 
| 120 | 120 | 
| 121 Session::~Session() { | 121 Session::~Session() { | 
| 122 #ifdef FLETCH_ENABLE_PRINT_INTERCEPTORS | 122 #ifdef DARTINO_ENABLE_PRINT_INTERCEPTORS | 
| 123   Print::UnregisterPrintInterceptors(); | 123   Print::UnregisterPrintInterceptors(); | 
| 124 #endif  // FLETCH_ENABLE_PRINT_INTERCEPTORS | 124 #endif  // DARTINO_ENABLE_PRINT_INTERCEPTORS | 
| 125 | 125 | 
| 126   delete connection_; | 126   delete connection_; | 
| 127   delete program_; | 127   delete program_; | 
| 128   delete main_thread_monitor_; | 128   delete main_thread_monitor_; | 
| 129   for (int i = 0; i < maps_.length(); ++i) delete maps_[i]; | 129   for (int i = 0; i < maps_.length(); ++i) delete maps_[i]; | 
| 130   maps_.Delete(); | 130   maps_.Delete(); | 
| 131 } | 131 } | 
| 132 | 132 | 
| 133 void Session::Initialize() { | 133 void Session::Initialize() { | 
| 134   program_ = new Program(Program::kBuiltViaSession); | 134   program_ = new Program(Program::kBuiltViaSession); | 
| (...skipping 1065 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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1725   Frame frame(stack); | 1725   Frame frame(stack); | 
| 1726   for (int i = 0; i <= frame_index; i++) frame.MovePrevious(); | 1726   for (int i = 0; i <= frame_index; i++) frame.MovePrevious(); | 
| 1727 | 1727 | 
| 1728   // Reset the return address to the entry function. | 1728   // Reset the return address to the entry function. | 
| 1729   frame.SetReturnAddress(reinterpret_cast<void*>(InterpreterEntry)); | 1729   frame.SetReturnAddress(reinterpret_cast<void*>(InterpreterEntry)); | 
| 1730 | 1730 | 
| 1731   // Finally resize the stack to the next frame pointer. | 1731   // Finally resize the stack to the next frame pointer. | 
| 1732   stack->SetTopFromPointer(frame.FramePointer()); | 1732   stack->SetTopFromPointer(frame.FramePointer()); | 
| 1733 } | 1733 } | 
| 1734 | 1734 | 
| 1735 }  // namespace fletch | 1735 }  // namespace dartino | 
| 1736 | 1736 | 
| 1737 #endif  // FLETCH_ENABLE_LIVE_CODING | 1737 #endif  // DARTINO_ENABLE_LIVE_CODING | 
| OLD | NEW | 
|---|