| 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 #include "src/vm/interpreter.h" | 5 #include "src/vm/interpreter.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 | 9 |
| 10 #include "src/shared/bytecodes.h" | 10 #include "src/shared/bytecodes.h" |
| 11 #include "src/shared/flags.h" | 11 #include "src/shared/flags.h" |
| 12 #include "src/shared/names.h" | 12 #include "src/shared/names.h" |
| 13 #include "src/shared/selectors.h" | 13 #include "src/shared/selectors.h" |
| 14 | 14 |
| 15 #include "src/vm/frame.h" | 15 #include "src/vm/frame.h" |
| 16 #include "src/vm/native_interpreter.h" | 16 #include "src/vm/native_interpreter.h" |
| 17 #include "src/vm/natives.h" | 17 #include "src/vm/natives.h" |
| 18 #include "src/vm/port.h" | 18 #include "src/vm/port.h" |
| 19 #include "src/vm/process.h" | 19 #include "src/vm/process.h" |
| 20 | 20 |
| 21 namespace fletch { | 21 namespace dartino { |
| 22 | 22 |
| 23 const NativeFunction kNativeTable[] = { | 23 const NativeFunction kNativeTable[] = { |
| 24 #define N(e, c, n, d) &Native_##e, | 24 #define N(e, c, n, d) &Native_##e, |
| 25 NATIVES_DO(N) | 25 NATIVES_DO(N) |
| 26 #undef N | 26 #undef N |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 class State { | 29 class State { |
| 30 public: | 30 public: |
| 31 explicit State(Process* process) | 31 explicit State(Process* process) |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 | 169 |
| 170 void HandleCoroutineChange(Process* process, Coroutine* coroutine) { | 170 void HandleCoroutineChange(Process* process, Coroutine* coroutine) { |
| 171 process->UpdateCoroutine(coroutine); | 171 process->UpdateCoroutine(coroutine); |
| 172 } | 172 } |
| 173 | 173 |
| 174 Object* HandleIdentical(Process* process, Object* left, Object* right) { | 174 Object* HandleIdentical(Process* process, Object* left, Object* right) { |
| 175 bool identical; | 175 bool identical; |
| 176 if (left == right) { | 176 if (left == right) { |
| 177 identical = true; | 177 identical = true; |
| 178 } else if (left->IsDouble() && right->IsDouble()) { | 178 } else if (left->IsDouble() && right->IsDouble()) { |
| 179 fletch_double_as_uint left_value = | 179 dartino_double_as_uint left_value = |
| 180 bit_cast<fletch_double_as_uint>(Double::cast(left)->value()); | 180 bit_cast<dartino_double_as_uint>(Double::cast(left)->value()); |
| 181 fletch_double_as_uint right_value = | 181 dartino_double_as_uint right_value = |
| 182 bit_cast<fletch_double_as_uint>(Double::cast(right)->value()); | 182 bit_cast<dartino_double_as_uint>(Double::cast(right)->value()); |
| 183 identical = (left_value == right_value); | 183 identical = (left_value == right_value); |
| 184 } else if (left->IsLargeInteger() && right->IsLargeInteger()) { | 184 } else if (left->IsLargeInteger() && right->IsLargeInteger()) { |
| 185 int64 left_value = LargeInteger::cast(left)->value(); | 185 int64 left_value = LargeInteger::cast(left)->value(); |
| 186 int64 right_value = LargeInteger::cast(right)->value(); | 186 int64 right_value = LargeInteger::cast(right)->value(); |
| 187 identical = (left_value == right_value); | 187 identical = (left_value == right_value); |
| 188 } else { | 188 } else { |
| 189 identical = false; | 189 identical = false; |
| 190 } | 190 } |
| 191 Program* program = process->program(); | 191 Program* program = process->program(); |
| 192 return identical ? program->true_object() : program->false_object(); | 192 return identical ? program->true_object() : program->false_object(); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 state.Advance(kEnterNoSuchMethodLength); | 349 state.Advance(kEnterNoSuchMethodLength); |
| 350 } else { | 350 } else { |
| 351 // Prepare for no such method. The code for invoking noSuchMethod is | 351 // Prepare for no such method. The code for invoking noSuchMethod is |
| 352 // located at the delta specified in the bytecode argument. | 352 // located at the delta specified in the bytecode argument. |
| 353 state.Push(receiver); | 353 state.Push(receiver); |
| 354 | 354 |
| 355 // These 3 arguments are passed to | 355 // These 3 arguments are passed to |
| 356 // lib/core/core_patch.dart:Object._noSuchMethod() | 356 // lib/core/core_patch.dart:Object._noSuchMethod() |
| 357 // | 357 // |
| 358 // The number of arguments must be kept in sync with | 358 // The number of arguments must be kept in sync with |
| 359 // pkg/fletchc/lib/src/fletch_backend.dart: | 359 // pkg/dartino_compiler/lib/src/dartino_backend.dart: |
| 360 // FletchBackend.codegenExternalNoSuchMethodTrampoline | 360 // DartinoBackend.codegenExternalNoSuchMethodTrampoline |
| 361 state.Push(receiver); | 361 state.Push(receiver); |
| 362 state.Push(clazz); | 362 state.Push(clazz); |
| 363 state.Push(selector_smi); | 363 state.Push(selector_smi); |
| 364 state.Advance(state.ReadByte(1)); | 364 state.Advance(state.ReadByte(1)); |
| 365 } | 365 } |
| 366 | 366 |
| 367 state.SaveState(); | 367 state.SaveState(); |
| 368 } | 368 } |
| 369 | 369 |
| 370 Function* HandleInvokeSelector(Process* process) { | 370 Function* HandleInvokeSelector(Process* process) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 396 // If we already are at the breakpoint, just clear it (to support stepping). | 396 // If we already are at the breakpoint, just clear it (to support stepping). |
| 397 if (debug_info->is_at_breakpoint()) { | 397 if (debug_info->is_at_breakpoint()) { |
| 398 debug_info->ClearBreakpoint(); | 398 debug_info->ClearBreakpoint(); |
| 399 } else if (debug_info->ShouldBreak(bcp, sp)) { | 399 } else if (debug_info->ShouldBreak(bcp, sp)) { |
| 400 return Interpreter::kBreakPoint; | 400 return Interpreter::kBreakPoint; |
| 401 } | 401 } |
| 402 } | 402 } |
| 403 return Interpreter::kReady; | 403 return Interpreter::kReady; |
| 404 } | 404 } |
| 405 | 405 |
| 406 } // namespace fletch | 406 } // namespace dartino |
| OLD | NEW |