| OLD | NEW | 
|     1 // Copyright (c) 2013, the Dart project authors.  Please see the AUTHORS file |     1 // Copyright (c) 2013, 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 <math.h>  // for isnan. |     5 #include <math.h>  // for isnan. | 
|     6 #include <setjmp.h> |     6 #include <setjmp.h> | 
|     7 #include <stdlib.h> |     7 #include <stdlib.h> | 
|     8  |     8  | 
|     9 #include "vm/globals.h" |     9 #include "vm/globals.h" | 
|    10 #if defined(TARGET_ARCH_MIPS) |    10 #if defined(TARGET_ARCH_MIPS) | 
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   494 #undef ARG_SIZE |   494 #undef ARG_SIZE | 
|   495  |   495  | 
|   496 #undef STR |   496 #undef STR | 
|   497 #undef XSTR |   497 #undef XSTR | 
|   498 } |   498 } | 
|   499  |   499  | 
|   500  |   500  | 
|   501 char* SimulatorDebugger::ReadLine(const char* prompt) { |   501 char* SimulatorDebugger::ReadLine(const char* prompt) { | 
|   502   char* result = NULL; |   502   char* result = NULL; | 
|   503   char line_buf[256]; |   503   char line_buf[256]; | 
|   504   int offset = 0; |   504   intptr_t offset = 0; | 
|   505   bool keep_going = true; |   505   bool keep_going = true; | 
|   506   OS::Print("%s", prompt); |   506   OS::Print("%s", prompt); | 
|   507   while (keep_going) { |   507   while (keep_going) { | 
|   508     if (fgets(line_buf, sizeof(line_buf), stdin) == NULL) { |   508     if (fgets(line_buf, sizeof(line_buf), stdin) == NULL) { | 
|   509       // fgets got an error. Just give up. |   509       // fgets got an error. Just give up. | 
|   510       if (result != NULL) { |   510       if (result != NULL) { | 
|   511         delete[] result; |   511         delete[] result; | 
|   512       } |   512       } | 
|   513       return NULL; |   513       return NULL; | 
|   514     } |   514     } | 
|   515     int len = strlen(line_buf); |   515     intptr_t len = strlen(line_buf); | 
|   516     if (len > 1 && |   516     if (len > 1 && | 
|   517         line_buf[len - 2] == '\\' && |   517         line_buf[len - 2] == '\\' && | 
|   518         line_buf[len - 1] == '\n') { |   518         line_buf[len - 1] == '\n') { | 
|   519       // When we read a line that ends with a "\" we remove the escape and |   519       // When we read a line that ends with a "\" we remove the escape and | 
|   520       // append the remainder. |   520       // append the remainder. | 
|   521       line_buf[len - 2] = '\n'; |   521       line_buf[len - 2] = '\n'; | 
|   522       line_buf[len - 1] = 0; |   522       line_buf[len - 1] = 0; | 
|   523       len -= 1; |   523       len -= 1; | 
|   524     } else if ((len > 0) && (line_buf[len - 1] == '\n')) { |   524     } else if ((len > 0) && (line_buf[len - 1] == '\n')) { | 
|   525       // Since we read a new line we are done reading the line. This |   525       // Since we read a new line we are done reading the line. This | 
|   526       // will exit the loop after copying this buffer into the result. |   526       // will exit the loop after copying this buffer into the result. | 
|   527       keep_going = false; |   527       keep_going = false; | 
|   528     } |   528     } | 
|   529     if (result == NULL) { |   529     if (result == NULL) { | 
|   530       // Allocate the initial result and make room for the terminating '\0' |   530       // Allocate the initial result and make room for the terminating '\0' | 
|   531       result = new char[len + 1]; |   531       result = new char[len + 1]; | 
|   532       if (result == NULL) { |   532       if (result == NULL) { | 
|   533         // OOM, so cannot readline anymore. |   533         // OOM, so cannot readline anymore. | 
|   534         return NULL; |   534         return NULL; | 
|   535       } |   535       } | 
|   536     } else { |   536     } else { | 
|   537       // Allocate a new result with enough room for the new addition. |   537       // Allocate a new result with enough room for the new addition. | 
|   538       int new_len = offset + len + 1; |   538       intptr_t new_len = offset + len + 1; | 
|   539       char* new_result = new char[new_len]; |   539       char* new_result = new char[new_len]; | 
|   540       if (new_result == NULL) { |   540       if (new_result == NULL) { | 
|   541         // OOM, free the buffer allocated so far and return NULL. |   541         // OOM, free the buffer allocated so far and return NULL. | 
|   542         delete[] result; |   542         delete[] result; | 
|   543         return NULL; |   543         return NULL; | 
|   544       } else { |   544       } else { | 
|   545         // Copy the existing input into the new array and set the new |   545         // Copy the existing input into the new array and set the new | 
|   546         // array as the result. |   546         // array as the result. | 
|   547         memmove(new_result, result, offset); |   547         memmove(new_result, result, offset); | 
|   548         delete[] result; |   548         delete[] result; | 
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   881 uint16_t Simulator::ReadHU(uword addr, Instr* instr) { |   881 uint16_t Simulator::ReadHU(uword addr, Instr* instr) { | 
|   882   if ((addr & 1) == 0) { |   882   if ((addr & 1) == 0) { | 
|   883     uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |   883     uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); | 
|   884     return *ptr; |   884     return *ptr; | 
|   885   } |   885   } | 
|   886   UnalignedAccess("unsigned halfword read", addr, instr); |   886   UnalignedAccess("unsigned halfword read", addr, instr); | 
|   887   return 0; |   887   return 0; | 
|   888 } |   888 } | 
|   889  |   889  | 
|   890  |   890  | 
|   891 int Simulator::ReadW(uword addr, Instr* instr) { |   891 intptr_t Simulator::ReadW(uword addr, Instr* instr) { | 
|   892   if ((addr & 3) == 0) { |   892   if ((addr & 3) == 0) { | 
|   893     intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |   893     intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); | 
|   894     return *ptr; |   894     return *ptr; | 
|   895   } |   895   } | 
|   896   UnalignedAccess("read", addr, instr); |   896   UnalignedAccess("read", addr, instr); | 
|   897   return 0; |   897   return 0; | 
|   898 } |   898 } | 
|   899  |   899  | 
|   900  |   900  | 
|   901 void Simulator::WriteB(uword addr, uint8_t value) { |   901 void Simulator::WriteB(uword addr, uint8_t value) { | 
|   902   uint8_t* ptr = reinterpret_cast<uint8_t*>(addr); |   902   uint8_t* ptr = reinterpret_cast<uint8_t*>(addr); | 
|   903   *ptr = value; |   903   *ptr = value; | 
|   904 } |   904 } | 
|   905  |   905  | 
|   906  |   906  | 
|   907 void Simulator::WriteH(uword addr, uint16_t value, Instr* instr) { |   907 void Simulator::WriteH(uword addr, uint16_t value, Instr* instr) { | 
|   908   if ((addr & 1) == 0) { |   908   if ((addr & 1) == 0) { | 
|   909     uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); |   909     uint16_t* ptr = reinterpret_cast<uint16_t*>(addr); | 
|   910     *ptr = value; |   910     *ptr = value; | 
|   911     return; |   911     return; | 
|   912   } |   912   } | 
|   913   UnalignedAccess("halfword write", addr, instr); |   913   UnalignedAccess("halfword write", addr, instr); | 
|   914 } |   914 } | 
|   915  |   915  | 
|   916  |   916  | 
|   917 void Simulator::WriteW(uword addr, int value, Instr* instr) { |   917 void Simulator::WriteW(uword addr, intptr_t value, Instr* instr) { | 
|   918   if ((addr & 3) == 0) { |   918   if ((addr & 3) == 0) { | 
|   919     intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); |   919     intptr_t* ptr = reinterpret_cast<intptr_t*>(addr); | 
|   920     *ptr = value; |   920     *ptr = value; | 
|   921     return; |   921     return; | 
|   922   } |   922   } | 
|   923   UnalignedAccess("write", addr, instr); |   923   UnalignedAccess("write", addr, instr); | 
|   924 } |   924 } | 
|   925  |   925  | 
|   926  |   926  | 
|   927 double Simulator::ReadD(uword addr, Instr* instr) { |   927 double Simulator::ReadD(uword addr, Instr* instr) { | 
| (...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2245   set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |  2245   set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 
|  2246   set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |  2246   set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 
|  2247   buf->Longjmp(); |  2247   buf->Longjmp(); | 
|  2248 } |  2248 } | 
|  2249  |  2249  | 
|  2250 }  // namespace dart |  2250 }  // namespace dart | 
|  2251  |  2251  | 
|  2252 #endif  // !defined(HOST_ARCH_MIPS) |  2252 #endif  // !defined(HOST_ARCH_MIPS) | 
|  2253  |  2253  | 
|  2254 #endif  // defined TARGET_ARCH_MIPS |  2254 #endif  // defined TARGET_ARCH_MIPS | 
| OLD | NEW |