OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 // External function | 382 // External function |
383 | 383 |
384 //---------------------------------------------------------------------------- | 384 //---------------------------------------------------------------------------- |
385 class IC_Utility; | 385 class IC_Utility; |
386 class SCTableReference; | 386 class SCTableReference; |
387 #ifdef ENABLE_DEBUGGER_SUPPORT | 387 #ifdef ENABLE_DEBUGGER_SUPPORT |
388 class Debug_Address; | 388 class Debug_Address; |
389 #endif | 389 #endif |
390 | 390 |
391 | 391 |
392 typedef void* ExternalReferenceRedirector(void* original, bool fp_return); | |
393 | |
394 | |
395 // An ExternalReference represents a C++ address used in the generated | 392 // An ExternalReference represents a C++ address used in the generated |
396 // code. All references to C++ functions and variables must be encapsulated in | 393 // code. All references to C++ functions and variables must be encapsulated in |
397 // an ExternalReference instance. This is done in order to track the origin of | 394 // an ExternalReference instance. This is done in order to track the origin of |
398 // all external references in the code so that they can be bound to the correct | 395 // all external references in the code so that they can be bound to the correct |
399 // addresses when deserializing a heap. | 396 // addresses when deserializing a heap. |
400 class ExternalReference BASE_EMBEDDED { | 397 class ExternalReference BASE_EMBEDDED { |
401 public: | 398 public: |
402 explicit ExternalReference(Builtins::CFunctionId id); | 399 explicit ExternalReference(Builtins::CFunctionId id); |
403 | 400 |
404 explicit ExternalReference(ApiFunction* ptr); | 401 explicit ExternalReference(ApiFunction* ptr); |
405 | 402 |
406 explicit ExternalReference(Builtins::Name name); | 403 explicit ExternalReference(Builtins::Name name); |
407 | 404 |
408 explicit ExternalReference(Runtime::FunctionId id); | 405 explicit ExternalReference(Runtime::FunctionId id); |
409 | 406 |
410 explicit ExternalReference(Runtime::Function* f); | 407 explicit ExternalReference(const Runtime::Function* f); |
411 | 408 |
412 explicit ExternalReference(const IC_Utility& ic_utility); | 409 explicit ExternalReference(const IC_Utility& ic_utility); |
413 | 410 |
414 #ifdef ENABLE_DEBUGGER_SUPPORT | 411 #ifdef ENABLE_DEBUGGER_SUPPORT |
415 explicit ExternalReference(const Debug_Address& debug_address); | 412 explicit ExternalReference(const Debug_Address& debug_address); |
416 #endif | 413 #endif |
417 | 414 |
418 explicit ExternalReference(StatsCounter* counter); | 415 explicit ExternalReference(StatsCounter* counter); |
419 | 416 |
420 explicit ExternalReference(Isolate::AddressId id); | 417 explicit ExternalReference(Isolate::AddressId id); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 static ExternalReference re_grow_stack(); | 492 static ExternalReference re_grow_stack(); |
496 | 493 |
497 // byte NativeRegExpMacroAssembler::word_character_bitmap | 494 // byte NativeRegExpMacroAssembler::word_character_bitmap |
498 static ExternalReference re_word_character_map(); | 495 static ExternalReference re_word_character_map(); |
499 | 496 |
500 #endif | 497 #endif |
501 | 498 |
502 // This lets you register a function that rewrites all external references. | 499 // This lets you register a function that rewrites all external references. |
503 // Used by the ARM simulator to catch calls to external references. | 500 // Used by the ARM simulator to catch calls to external references. |
504 static void set_redirector(ExternalReferenceRedirector* redirector) { | 501 static void set_redirector(ExternalReferenceRedirector* redirector) { |
505 ASSERT(redirector_ == NULL); // We can't stack them. | 502 // We can't stack them. |
506 redirector_ = redirector; | 503 ASSERT(Isolate::Current()->external_reference_redirector() == NULL); |
| 504 Isolate::Current()->set_external_reference_redirector(redirector); |
507 } | 505 } |
508 | 506 |
509 private: | 507 private: |
510 explicit ExternalReference(void* address) | 508 explicit ExternalReference(void* address) |
511 : address_(address) {} | 509 : address_(address) {} |
512 | 510 |
513 static ExternalReferenceRedirector* redirector_; | |
514 | |
515 static void* Redirect(void* address, bool fp_return = false) { | 511 static void* Redirect(void* address, bool fp_return = false) { |
516 if (redirector_ == NULL) return address; | 512 ExternalReferenceRedirector* redirector = |
517 void* answer = (*redirector_)(address, fp_return); | 513 Isolate::Current()->external_reference_redirector(); |
| 514 if (redirector == NULL) return address; |
| 515 void* answer = (*redirector)(address, fp_return); |
518 return answer; | 516 return answer; |
519 } | 517 } |
520 | 518 |
521 static void* Redirect(Address address_arg, bool fp_return = false) { | 519 static void* Redirect(Address address_arg, bool fp_return = false) { |
| 520 ExternalReferenceRedirector* redirector = |
| 521 Isolate::Current()->external_reference_redirector(); |
522 void* address = reinterpret_cast<void*>(address_arg); | 522 void* address = reinterpret_cast<void*>(address_arg); |
523 void* answer = (redirector_ == NULL) ? | 523 void* answer = (redirector == NULL) ? |
524 address : | 524 address : |
525 (*redirector_)(address, fp_return); | 525 (*redirector)(address, fp_return); |
526 return answer; | 526 return answer; |
527 } | 527 } |
528 | 528 |
529 void* address_; | 529 void* address_; |
530 }; | 530 }; |
531 | 531 |
532 | 532 |
533 // ----------------------------------------------------------------------------- | 533 // ----------------------------------------------------------------------------- |
534 // Utility functions | 534 // Utility functions |
535 | 535 |
(...skipping 27 matching lines...) Expand all Loading... |
563 unsigned int num_bits_set; | 563 unsigned int num_bits_set; |
564 for (num_bits_set = 0; x; x >>= 1) { | 564 for (num_bits_set = 0; x; x >>= 1) { |
565 num_bits_set += x & 1; | 565 num_bits_set += x & 1; |
566 } | 566 } |
567 return num_bits_set; | 567 return num_bits_set; |
568 } | 568 } |
569 | 569 |
570 } } // namespace v8::internal | 570 } } // namespace v8::internal |
571 | 571 |
572 #endif // V8_ASSEMBLER_H_ | 572 #endif // V8_ASSEMBLER_H_ |
OLD | NEW |