Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: src/assembler.h

Issue 119036: * Modify simulator and ARM code generator to avoid swi... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/assembler.h
===================================================================
--- src/assembler.h (revision 2053)
+++ src/assembler.h (working copy)
@@ -352,10 +352,15 @@
class Debug_Address;
#endif
-// An ExternalReference represents a C++ address called from the generated
-// code. All references to C++ functions and must be encapsulated in an
-// ExternalReference instance. This is done in order to track the origin of
-// all external references in the code.
+
+typedef void* ExternalReferenceRedirector(void* original, bool fp_return);
+
+
+// An ExternalReference represents a C++ address used in the generated
+// code. All references to C++ functions and variables must be encapsulated in
+// an ExternalReference instance. This is done in order to track the origin of
+// all external references in the code so that they can be bound to the correct
+// addresses when deserializing a heap.
class ExternalReference BASE_EMBEDDED {
public:
explicit ExternalReference(Builtins::CFunctionId id);
@@ -382,6 +387,8 @@
// pattern. This means that they have to be added to the
// ExternalReferenceTable in serialize.cc manually.
+ static ExternalReference perform_gc_function();
+
static ExternalReference builtin_passed_function();
// Static variable Factory::the_hole_value.location()
@@ -403,7 +410,7 @@
static ExternalReference double_fp_operation(Token::Value operation);
- Address address() const {return address_;}
+ Address address() const {return reinterpret_cast<Address>(address_);}
#ifdef ENABLE_DEBUGGER_SUPPORT
// Function Debug::Break()
@@ -413,11 +420,30 @@
static ExternalReference debug_step_in_fp_address();
#endif
+ // This lets you register a function that rewrites all external references.
+ // Used by the ARM simulator to catch calls to external references.
+ static void set_redirector(ExternalReferenceRedirector* redirector) {
+ ASSERT(redirector_ == NULL); // We can't stack them.
+ redirector_ = redirector;
+ }
+
private:
explicit ExternalReference(void* address)
- : address_(reinterpret_cast<Address>(address)) {}
+ : address_(address) {}
- Address address_;
+ static ExternalReferenceRedirector* redirector_;
+
+ static void* Redirect(void* address, bool fp_return = false) {
+ if (redirector_ == NULL) return address;
+ return (*redirector_)(address, fp_return);
+ }
+
+ static void* Redirect(Address address_arg, bool fp_return = false) {
+ void* address = reinterpret_cast<void*>(address_arg);
+ return redirector_ == NULL ? address : (*redirector_)(address, fp_return);
+ }
+
+ void* address_;
};

Powered by Google App Engine
This is Rietveld 408576698