Make v8 compilable without V8_USE_UNSAFE_HANDLES.
authordcarney@chromium.org <dcarney@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 6 May 2013 13:01:03 +0000 (13:01 +0000)
committerdcarney@chromium.org <dcarney@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 6 May 2013 13:01:03 +0000 (13:01 +0000)
Without this modification, we get this error: "dereferencing type-punned pointer
will break strict-aliasing rules" (GCC strict aliasing).

Also included small CcTest sanity fixes: isolate() cannot return anything else
than default_isolate().

BUG=
TBR=dcarney@chromium.org

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

Patch from Marja Hölttä <marja@chromium.org>.

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

test/cctest/cctest.h

index 30cbe79..5a376c7 100644 (file)
@@ -83,19 +83,21 @@ class CcTest {
   const char* name() { return name_; }
   const char* dependency() { return dependency_; }
   bool enabled() { return enabled_; }
-  static void set_default_isolate(v8::Isolate* default_isolate) {
-    default_isolate_ = default_isolate;
-  }
   static v8::Isolate* default_isolate() { return default_isolate_; }
-  static v8::Isolate* isolate() { return context()->GetIsolate(); }
-  static v8::Handle<v8::Context> env() { return context(); }
+
+  static v8::Handle<v8::Context> env() {
+    return v8::Local<v8::Context>::New(default_isolate_, context_);
+  }
+
+  static v8::Isolate* isolate() { return default_isolate_; }
 
   // Helper function to initialize the VM.
   static void InitializeVM(CcTestExtensionFlags extensions = NO_EXTENSIONS);
 
  private:
-  static v8::Handle<v8::Context> context() {
-      return *reinterpret_cast<v8::Handle<v8::Context>*>(&context_);
+  friend int main(int argc, char** argv);
+  static void set_default_isolate(v8::Isolate* default_isolate) {
+    default_isolate_ = default_isolate;
   }
   TestFunction* callback_;
   const char* file_;