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

Unified Diff: sky/engine/bindings/core/v8/ScriptWrappable.h

Issue 719063002: Revert "Remove support for MSVC" (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | sky/engine/bindings/core/v8/ScriptWrappable.cpp » ('j') | sky/engine/wtf/Compiler.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/bindings/core/v8/ScriptWrappable.h
diff --git a/sky/engine/bindings/core/v8/ScriptWrappable.h b/sky/engine/bindings/core/v8/ScriptWrappable.h
index 3f5f3a8a68f777fa7c69fba035df91b9da64fc49..77445f92147ad210eacc3b451f54e874f9b96283 100644
--- a/sky/engine/bindings/core/v8/ScriptWrappable.h
+++ b/sky/engine/bindings/core/v8/ScriptWrappable.h
@@ -48,6 +48,26 @@ namespace blink {
* variable which increase the size of instances. Some of the classes sensitive
* to the size inherit from this class. So this class must be zero size.
*/
+#if COMPILER(MSVC)
+// VC++ 2013 doesn't support EBCO (Empty Base Class Optimization). It causes
+// that not always pointers to an empty base class are aligned to 4 byte
+// alignment. For example,
+//
+// class EmptyBase1 {};
+// class EmptyBase2 {};
+// class Derived : public EmptyBase1, public EmptyBase2 {};
+// Derived d;
+// // &d == 0x1000
+// // static_cast<EmptyBase1*>(&d) == 0x1000
+// // static_cast<EmptyBase2*>(&d) == 0x1001 // Not 4 byte alignment!
+//
+// This doesn't happen with other compilers which support EBCO. All the
+// addresses in the above example will be 0x1000 with EBCO supported.
+//
+// Since v8::Object::SetAlignedPointerInInternalField requires the pointers to
+// be aligned, we need a hack to specify at least 4 byte alignment to MSVC.
+__declspec(align(4))
+#endif
class ScriptWrappableBase {
public:
template<typename T>
« no previous file with comments | « no previous file | sky/engine/bindings/core/v8/ScriptWrappable.cpp » ('j') | sky/engine/wtf/Compiler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698