Allow platforms (linux and win32) to not force 16-byte alignment
authorkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 23 Sep 2008 10:06:58 +0000 (10:06 +0000)
committerkasperl@chromium.org <kasperl@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 23 Sep 2008 10:06:58 +0000 (10:06 +0000)
of activation frames (needed on Mac OS X).
Review URL: http://codereview.chromium.org/4211

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

src/codegen-ia32.cc
src/platform-linux.cc
src/platform-macos.cc
src/platform-win32.cc
src/platform.h

index be8b113..76c0cb2 100644 (file)
@@ -5209,11 +5209,11 @@ void CEntryStub::GenerateReserveCParameterSpace(MacroAssembler* masm,
   if (num_parameters > 0) {
     __ sub(Operand(esp), Immediate(num_parameters * kPointerSize));
   }
-  // OS X activation frames are 16 byte-aligned
-  // (see "Mac OS X ABI Function Call Guide").
-  const int kFrameAlignment = 16;
-  ASSERT(IsPowerOf2(kFrameAlignment));
-  __ and_(esp, -kFrameAlignment);
+  static const int kFrameAlignment = OS::ActivationFrameAlignment();
+  if (kFrameAlignment > 0) {
+    ASSERT(IsPowerOf2(kFrameAlignment));
+    __ and_(esp, -kFrameAlignment);
+  }
 }
 
 
index 1dcf2cc..46ca7dc 100644 (file)
@@ -195,7 +195,16 @@ char *OS::StrDup(const char* str) {
 }
 
 
-double OS::nan_value() { return NAN; }
+double OS::nan_value() {
+  return NAN;
+}
+
+
+int OS::ActivationFrameAlignment() {
+  // No constraint on Linux.
+  return 0;
+}
+
 
 // We keep the lowest and highest addresses mapped as a quick way of
 // determining that pointers are outside the heap (used mostly in assertions
index 54aad6a..e57f79d 100644 (file)
@@ -300,7 +300,16 @@ void OS::LogSharedLibraryAddresses() {
 }
 
 
-double OS::nan_value() { return NAN; }
+double OS::nan_value() {
+  return NAN;
+}
+
+
+int OS::ActivationFrameAlignment() {
+  // OS X activation frames must be 16 byte-aligned; see "Mac OS X ABI
+  // Function Call Guide".
+  return 16;
+}
 
 
 int OS::StackWalk(StackFrame* frames, int frames_size) {
index 747f0a4..4fdbf78 100644 (file)
@@ -1206,6 +1206,13 @@ double OS::nan_value() {
   return *reinterpret_cast<const double*>(&nanval);
 }
 
+
+int OS::ActivationFrameAlignment() {
+  // No constraint on Windows.
+  return 0;
+}
+
+
 bool VirtualMemory::IsReserved() {
   return address_ != NULL;
 }
index 5bb7f20..0e33fa8 100644 (file)
@@ -217,6 +217,10 @@ class OS {
   // Returns the double constant NAN
   static double nan_value();
 
+  // Returns the activation frame alignment constraint or zero if
+  // the platform doesn't care. Guaranteed to be a power of two.
+  static int ActivationFrameAlignment();
+
  private:
   static const int msPerSecond = 1000;