OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 return new Redirection(external_function, type); | 485 return new Redirection(external_function, type); |
486 } | 486 } |
487 | 487 |
488 static Redirection* FromHltInstruction(Instruction* redirect_call) { | 488 static Redirection* FromHltInstruction(Instruction* redirect_call) { |
489 char* addr_of_hlt = reinterpret_cast<char*>(redirect_call); | 489 char* addr_of_hlt = reinterpret_cast<char*>(redirect_call); |
490 char* addr_of_redirection = | 490 char* addr_of_redirection = |
491 addr_of_hlt - OFFSET_OF(Redirection, redirect_call_); | 491 addr_of_hlt - OFFSET_OF(Redirection, redirect_call_); |
492 return reinterpret_cast<Redirection*>(addr_of_redirection); | 492 return reinterpret_cast<Redirection*>(addr_of_redirection); |
493 } | 493 } |
494 | 494 |
| 495 static void* ReverseRedirection(int64_t reg) { |
| 496 Redirection* redirection = |
| 497 FromHltInstruction(reinterpret_cast<Instruction*>(reg)); |
| 498 return redirection->external_function(); |
| 499 } |
| 500 |
495 private: | 501 private: |
496 void* external_function_; | 502 void* external_function_; |
497 Instruction redirect_call_; | 503 Instruction redirect_call_; |
498 ExternalReference::Type type_; | 504 ExternalReference::Type type_; |
499 Redirection* next_; | 505 Redirection* next_; |
500 }; | 506 }; |
501 | 507 |
502 | 508 |
503 void* Simulator::RedirectExternalReference(void* external_function, | 509 void* Simulator::RedirectExternalReference(void* external_function, |
504 ExternalReference::Type type) { | 510 ExternalReference::Type type) { |
(...skipping 2510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3015 int64_t arg7); | 3021 int64_t arg7); |
3016 | 3022 |
3017 typedef int64_t (*SimulatorRuntimeCompareCall)(double arg1, double arg2); | 3023 typedef int64_t (*SimulatorRuntimeCompareCall)(double arg1, double arg2); |
3018 typedef double (*SimulatorRuntimeFPFPCall)(double arg1, double arg2); | 3024 typedef double (*SimulatorRuntimeFPFPCall)(double arg1, double arg2); |
3019 typedef double (*SimulatorRuntimeFPCall)(double arg1); | 3025 typedef double (*SimulatorRuntimeFPCall)(double arg1); |
3020 typedef double (*SimulatorRuntimeFPIntCall)(double arg1, int32_t arg2); | 3026 typedef double (*SimulatorRuntimeFPIntCall)(double arg1, int32_t arg2); |
3021 | 3027 |
3022 // This signature supports direct call in to API function native callback | 3028 // This signature supports direct call in to API function native callback |
3023 // (refer to InvocationCallback in v8.h). | 3029 // (refer to InvocationCallback in v8.h). |
3024 typedef void (*SimulatorRuntimeDirectApiCall)(int64_t arg0); | 3030 typedef void (*SimulatorRuntimeDirectApiCall)(int64_t arg0); |
3025 typedef void (*SimulatorRuntimeProfilingApiCall)(int64_t arg0, int64_t arg1); | 3031 typedef void (*SimulatorRuntimeProfilingApiCall)(int64_t arg0, void* arg1); |
3026 | 3032 |
3027 // This signature supports direct call to accessor getter callback. | 3033 // This signature supports direct call to accessor getter callback. |
3028 typedef void (*SimulatorRuntimeDirectGetterCall)(int64_t arg0, int64_t arg1); | 3034 typedef void (*SimulatorRuntimeDirectGetterCall)(int64_t arg0, int64_t arg1); |
3029 typedef void (*SimulatorRuntimeProfilingGetterCall)(int64_t arg0, int64_t arg1, | 3035 typedef void (*SimulatorRuntimeProfilingGetterCall)(int64_t arg0, int64_t arg1, |
3030 int64_t arg2); | 3036 void* arg2); |
3031 | 3037 |
3032 void Simulator::VisitException(Instruction* instr) { | 3038 void Simulator::VisitException(Instruction* instr) { |
3033 // Define some colour codes to use for log messages. | 3039 // Define some colour codes to use for log messages. |
3034 // TODO(jbramley): Find a more elegant way of defining these. | 3040 // TODO(jbramley): Find a more elegant way of defining these. |
3035 char const* const clr_normal = (FLAG_log_colour) ? ("\033[m") | 3041 char const* const clr_normal = (FLAG_log_colour) ? ("\033[m") |
3036 : (""); | 3042 : (""); |
3037 char const* const clr_debug_number = (FLAG_log_colour) ? ("\033[1;33m") | 3043 char const* const clr_debug_number = (FLAG_log_colour) ? ("\033[1;33m") |
3038 : (""); | 3044 : (""); |
3039 char const* const clr_debug_message = (FLAG_log_colour) ? ("\033[0;33m") | 3045 char const* const clr_debug_message = (FLAG_log_colour) ? ("\033[0;33m") |
3040 : (""); | 3046 : (""); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3166 result.res0, result.res1); | 3172 result.res0, result.res1); |
3167 #ifdef DEBUG | 3173 #ifdef DEBUG |
3168 CorruptAllCallerSavedCPURegisters(); | 3174 CorruptAllCallerSavedCPURegisters(); |
3169 #endif | 3175 #endif |
3170 set_xreg(0, result.res0); | 3176 set_xreg(0, result.res0); |
3171 set_xreg(1, result.res1); | 3177 set_xreg(1, result.res1); |
3172 break; | 3178 break; |
3173 } | 3179 } |
3174 | 3180 |
3175 case ExternalReference::DIRECT_API_CALL: { | 3181 case ExternalReference::DIRECT_API_CALL: { |
3176 // void f(v8::Arguments&) | 3182 // void f(v8::FunctionCallbackInfo&) |
3177 TraceSim("Type: DIRECT_API_CALL\n"); | 3183 TraceSim("Type: DIRECT_API_CALL\n"); |
3178 SimulatorRuntimeDirectApiCall target = | 3184 SimulatorRuntimeDirectApiCall target = |
3179 reinterpret_cast<SimulatorRuntimeDirectApiCall>(external); | 3185 reinterpret_cast<SimulatorRuntimeDirectApiCall>(external); |
3180 TraceSim("Arguments: 0x%016" PRIx64 "\n", xreg(0)); | 3186 TraceSim("Arguments: 0x%016" PRIx64 "\n", xreg(0)); |
3181 target(xreg(0)); | 3187 target(xreg(0)); |
3182 TraceSim("No return value."); | 3188 TraceSim("No return value."); |
3183 #ifdef DEBUG | 3189 #ifdef DEBUG |
3184 CorruptAllCallerSavedCPURegisters(); | 3190 CorruptAllCallerSavedCPURegisters(); |
3185 #endif | 3191 #endif |
3186 break; | 3192 break; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3240 double result = target(dreg(0), wreg(0)); | 3246 double result = target(dreg(0), wreg(0)); |
3241 TraceSim("Returned: %f\n", result); | 3247 TraceSim("Returned: %f\n", result); |
3242 #ifdef DEBUG | 3248 #ifdef DEBUG |
3243 CorruptAllCallerSavedCPURegisters(); | 3249 CorruptAllCallerSavedCPURegisters(); |
3244 #endif | 3250 #endif |
3245 set_dreg(0, result); | 3251 set_dreg(0, result); |
3246 break; | 3252 break; |
3247 } | 3253 } |
3248 | 3254 |
3249 case ExternalReference::DIRECT_GETTER_CALL: { | 3255 case ExternalReference::DIRECT_GETTER_CALL: { |
3250 // void f(Local<String> property, AccessorInfo& info) | 3256 // void f(Local<String> property, PropertyCallbackInfo& info) |
3251 TraceSim("Type: DIRECT_GETTER_CALL\n"); | 3257 TraceSim("Type: DIRECT_GETTER_CALL\n"); |
3252 SimulatorRuntimeDirectGetterCall target = | 3258 SimulatorRuntimeDirectGetterCall target = |
3253 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); | 3259 reinterpret_cast<SimulatorRuntimeDirectGetterCall>(external); |
3254 TraceSim("Arguments: 0x%016" PRIx64 ", 0x%016" PRIx64 "\n", | 3260 TraceSim("Arguments: 0x%016" PRIx64 ", 0x%016" PRIx64 "\n", |
3255 xreg(0), xreg(1)); | 3261 xreg(0), xreg(1)); |
3256 target(xreg(0), xreg(1)); | 3262 target(xreg(0), xreg(1)); |
3257 TraceSim("No return value."); | 3263 TraceSim("No return value."); |
3258 #ifdef DEBUG | 3264 #ifdef DEBUG |
3259 CorruptAllCallerSavedCPURegisters(); | 3265 CorruptAllCallerSavedCPURegisters(); |
3260 #endif | 3266 #endif |
3261 break; | 3267 break; |
3262 } | 3268 } |
3263 | 3269 |
3264 case ExternalReference::PROFILING_API_CALL: { | 3270 case ExternalReference::PROFILING_API_CALL: { |
3265 // void f(v8::Arguments&, v8::FunctionCallback) | 3271 // void f(v8::FunctionCallbackInfo&, v8::FunctionCallback) |
3266 TraceSim("Type: PROFILING_API_CALL\n"); | 3272 TraceSim("Type: PROFILING_API_CALL\n"); |
3267 SimulatorRuntimeProfilingApiCall target = | 3273 SimulatorRuntimeProfilingApiCall target = |
3268 reinterpret_cast<SimulatorRuntimeProfilingApiCall>(external); | 3274 reinterpret_cast<SimulatorRuntimeProfilingApiCall>(external); |
3269 TraceSim("Arguments: 0x%016" PRIx64 ", 0x%016" PRIx64 "\n", | 3275 void* arg1 = Redirection::ReverseRedirection(xreg(1)); |
3270 xreg(0), xreg(1)); | 3276 TraceSim("Arguments: 0x%016" PRIx64 ", %p\n", xreg(0), arg1); |
3271 target(xreg(0), xreg(1)); | 3277 target(xreg(0), arg1); |
3272 TraceSim("No return value."); | 3278 TraceSim("No return value."); |
3273 #ifdef DEBUG | 3279 #ifdef DEBUG |
3274 CorruptAllCallerSavedCPURegisters(); | 3280 CorruptAllCallerSavedCPURegisters(); |
3275 #endif | 3281 #endif |
3276 break; | 3282 break; |
3277 } | 3283 } |
3278 | 3284 |
3279 case ExternalReference::PROFILING_GETTER_CALL: { | 3285 case ExternalReference::PROFILING_GETTER_CALL: { |
3280 // void f(Local<String> property, AccessorInfo& info, | 3286 // void f(Local<String> property, PropertyCallbackInfo& info, |
3281 // AccessorGetterCallback callback) | 3287 // AccessorGetterCallback callback) |
3282 TraceSim("Type: PROFILING_GETTER_CALL\n"); | 3288 TraceSim("Type: PROFILING_GETTER_CALL\n"); |
3283 SimulatorRuntimeProfilingGetterCall target = | 3289 SimulatorRuntimeProfilingGetterCall target = |
3284 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>( | 3290 reinterpret_cast<SimulatorRuntimeProfilingGetterCall>( |
3285 external); | 3291 external); |
3286 TraceSim("Arguments: " | 3292 void* arg2 = Redirection::ReverseRedirection(xreg(2)); |
3287 "0x%016" PRIx64 ", 0x%016" PRIx64 ", 0x%016" PRIx64 "\n", | 3293 TraceSim("Arguments: 0x%016" PRIx64 ", 0x%016" PRIx64 ", %p\n", |
3288 xreg(0), xreg(1), xreg(2)); | 3294 xreg(0), xreg(1), arg2); |
3289 target(xreg(0), xreg(1), xreg(2)); | 3295 target(xreg(0), xreg(1), arg2); |
3290 TraceSim("No return value."); | 3296 TraceSim("No return value."); |
3291 #ifdef DEBUG | 3297 #ifdef DEBUG |
3292 CorruptAllCallerSavedCPURegisters(); | 3298 CorruptAllCallerSavedCPURegisters(); |
3293 #endif | 3299 #endif |
3294 break; | 3300 break; |
3295 } | 3301 } |
3296 } | 3302 } |
3297 | 3303 |
3298 set_lr(return_address); | 3304 set_lr(return_address); |
3299 set_pc(return_address); | 3305 set_pc(return_address); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3346 default: | 3352 default: |
3347 UNIMPLEMENTED(); | 3353 UNIMPLEMENTED(); |
3348 } | 3354 } |
3349 } | 3355 } |
3350 | 3356 |
3351 #endif // USE_SIMULATOR | 3357 #endif // USE_SIMULATOR |
3352 | 3358 |
3353 } } // namespace v8::internal | 3359 } } // namespace v8::internal |
3354 | 3360 |
3355 #endif // V8_TARGET_ARCH_A64 | 3361 #endif // V8_TARGET_ARCH_A64 |
OLD | NEW |