Reviewers: Sven Panne,

Description:
Add a getter for the address and size of the code range to the pulic API

Since the x64 backend currently doesn't emit ABI compliant code, it is
not possible to unwind the stack. During Win64 SEH this will cause the
exception handling to abort, and not even call the unhandled exception
handler. Embedders are advised to install a custom unwind callback using
RtlInstallFunctionTableCallback for the entire code range to catch
unwind attempts for exception handling.

BUG=v8:3598
[email protected]
LOG=y

Please review this at https://codereview.chromium.org/612043002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+28, -0 lines):
  M include/v8.h
  M src/api.cc
  M src/heap/spaces.h


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index ec1941e6fd86eec42707e4d41011112961fe2109..dab3a05991737650d53595af9df024d43b08feee 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4835,6 +4835,18 @@ class V8_EXPORT Isolate {
    */
   void SetStackLimit(uintptr_t stack_limit);

+  /**
+   * Returns a memory range that can potentially contain jitted code.
+   *
+ * On Win64, embedders are advised to install function table callbacks for + * these ranges, as default SEH won't be able to unwind through jitted code.
+   *
+   * Might be empty on other platforms.
+   *
+   * https://code.google.com/p/v8/issues/detail?id=3598
+   */
+  void GetCodeRange(void** start, size_t* length_in_bytes);
+
  private:
   template<class K, class V, class Traits> friend class PersistentValueMap;

Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index bda34bdfacacbb369f5e8db2b18d03c6f38b1ec7..6af7638492d98cfbd2e6aaebd513582e263b2ad8 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6813,6 +6813,18 @@ void v8::Isolate::SetStackLimit(uintptr_t stack_limit) {
 }


+void v8::Isolate::GetCodeRange(void** start, size_t* length_in_bytes) {
+  i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
+  if (isolate->code_range() && isolate->code_range()->valdi()) {
+    *start = isolate->code_range()->start();
+    *length_in_bytes = isolate->code_range()->size();
+  } else {
+    *start = NULL;
+    *length_in_bytes = 0;
+  }
+}
+
+
 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj)
     : str_(NULL), length_(0) {
   i::Isolate* isolate = i::Isolate::Current();
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index 1a8944995d32d419213214de5ce977c326a6205f..ef55357163924af08705b59366101e4747069b46 100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -880,6 +880,10 @@ class CodeRange {
     DCHECK(valid());
     return static_cast<Address>(code_range_->address());
   }
+  size_t size() {
+    DCHECK(valid());
+    return code_range_->size();
+  }
   bool contains(Address address) {
     if (!valid()) return false;
     Address start = static_cast<Address>(code_range_->address());


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to