Add a getter for the address and size of the code range to the pulic API
authorjochen@chromium.org <jochen@chromium.org>
Mon, 29 Sep 2014 12:17:31 +0000 (12:17 +0000)
committerjochen@chromium.org <jochen@chromium.org>
Mon, 29 Sep 2014 12:17:31 +0000 (12:17 +0000)
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
R=svenpanne@chromium.org
LOG=y

Review URL: https://codereview.chromium.org/612043002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24283 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

include/v8.h
src/api.cc
src/heap/spaces.h

index 07d380e..63c6762 100644 (file)
@@ -4847,6 +4847,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 a442f76..0fbdf7b 100644 (file)
@@ -6826,6 +6826,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()->valid()) {
+    *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 1a89449..ef55357 100644 (file)
@@ -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());