OSDN Git Service

Make frame size dependent on arch-specific constants.
authorAndreas Gampe <agampe@google.com>
Thu, 3 Apr 2014 20:31:32 +0000 (13:31 -0700)
committerAndreas Gampe <agampe@google.com>
Thu, 3 Apr 2014 20:31:32 +0000 (13:31 -0700)
Necessary for proper cross-compiling.

Change-Id: I852901ee6ca5121e480b83a8e318bdc9c7d615e8

compiler/oat_writer.cc
runtime/globals.h
runtime/runtime.cc
runtime/stack_indirect_reference_table.h

index a07aebc..2d45a2f 100644 (file)
@@ -508,7 +508,12 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index,
           refs++;
         }
       }
-      size_t sirt_size = StackIndirectReferenceTable::GetAlignedSirtSize(refs);
+      InstructionSet trg_isa = compiler_driver_->GetInstructionSet();
+      size_t pointer_size = 4;
+      if (trg_isa == kArm64 || trg_isa == kX86_64) {
+        pointer_size = 8;
+      }
+      size_t sirt_size = StackIndirectReferenceTable::GetAlignedSirtSizeTarget(pointer_size, refs);
 
       // Get the generic spill masks and base frame size.
       mirror::ArtMethod* callee_save_method =
index f2d6862..ee8dc07 100644 (file)
@@ -31,9 +31,17 @@ static constexpr size_t KB = 1024;
 static constexpr size_t MB = KB * KB;
 static constexpr size_t GB = KB * KB * KB;
 
+// Runtime sizes.
 static constexpr size_t kWordSize = sizeof(word);
 static constexpr size_t kPointerSize = sizeof(void*);
 
+// Architecture-specific pointer sizes
+static constexpr size_t kArmPointerSize = 4;
+static constexpr size_t kArm64PointerSize = 8;
+static constexpr size_t kMipsPointerSize = 4;
+static constexpr size_t kX86PointerSize = 4;
+static constexpr size_t kX86_64PointerSize = 8;
+
 static constexpr size_t kBitsPerByte = 8;
 static constexpr size_t kBitsPerByteLog2 = 3;
 static constexpr int kBitsPerWord = kWordSize * kBitsPerByte;
index f8634ce..edc3b33 100644 (file)
@@ -999,7 +999,7 @@ mirror::ArtMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_se
     uint32_t fp_spills = type == kSaveAll ? fp_all_spills : 0;
     size_t frame_size = RoundUp((__builtin_popcount(core_spills) /* gprs */ +
                                  __builtin_popcount(fp_spills) /* fprs */ +
-                                 1 /* Method* */) * kPointerSize, kStackAlignment);
+                                 1 /* Method* */) * kArmPointerSize, kStackAlignment);
     method->SetFrameSizeInBytes(frame_size);
     method->SetCoreSpillMask(core_spills);
     method->SetFpSpillMask(fp_spills);
@@ -1013,7 +1013,7 @@ mirror::ArtMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_se
                            (type == kSaveAll ? all_spills : 0) | (1 << art::mips::RA);
     size_t frame_size = RoundUp((__builtin_popcount(core_spills) /* gprs */ +
                                 (type == kRefsAndArgs ? 0 : 3) + 1 /* Method* */) *
-                                kPointerSize, kStackAlignment);
+                                kMipsPointerSize, kStackAlignment);
     method->SetFrameSizeInBytes(frame_size);
     method->SetCoreSpillMask(core_spills);
     method->SetFpSpillMask(0);
@@ -1023,7 +1023,7 @@ mirror::ArtMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_se
     uint32_t core_spills = ref_spills | (type == kRefsAndArgs ? arg_spills : 0) |
                          (1 << art::x86::kNumberOfCpuRegisters);  // fake return address callee save
     size_t frame_size = RoundUp((__builtin_popcount(core_spills) /* gprs */ +
-                                 1 /* Method* */) * kPointerSize, kStackAlignment);
+                                 1 /* Method* */) * kX86PointerSize, kStackAlignment);
     method->SetFrameSizeInBytes(frame_size);
     method->SetCoreSpillMask(core_spills);
     method->SetFpSpillMask(0);
@@ -1043,7 +1043,7 @@ mirror::ArtMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_se
     uint32_t fp_spills = (type == kRefsAndArgs ? fp_arg_spills : 0);
     size_t frame_size = RoundUp((__builtin_popcount(core_spills) /* gprs */ +
                                  __builtin_popcount(fp_spills) /* fprs */ +
-                                 1 /* Method* */) * kPointerSize, kStackAlignment);
+                                 1 /* Method* */) * kX86_64PointerSize, kStackAlignment);
     method->SetFrameSizeInBytes(frame_size);
     method->SetCoreSpillMask(core_spills);
     method->SetFpSpillMask(fp_spills);
@@ -1083,7 +1083,7 @@ mirror::ArtMethod* Runtime::CreateCalleeSaveMethod(InstructionSet instruction_se
                           | (type == kSaveAll ? fp_all_spills : 0);
       size_t frame_size = RoundUp((__builtin_popcount(core_spills) /* gprs */ +
                                    __builtin_popcount(fp_spills) /* fprs */ +
-                                   1 /* Method* */) * kPointerSize, kStackAlignment);
+                                   1 /* Method* */) * kArm64PointerSize, kStackAlignment);
       method->SetFrameSizeInBytes(frame_size);
       method->SetCoreSpillMask(core_spills);
       method->SetFpSpillMask(fp_spills);
index daef3ff..6049e06 100644 (file)
@@ -57,6 +57,16 @@ class StackIndirectReferenceTable {
     return RoundUp(sirt_size, 8);
   }
 
+  // Get the size of the SIRT for the number of entries, with padding added for potential alignment.
+  static size_t GetAlignedSirtSizeTarget(size_t pointer_size, uint32_t num_references) {
+    // Assume that the layout is packed.
+    size_t header_size = pointer_size + sizeof(uint32_t);
+    // This assumes there is no layout change between 32 and 64b.
+    size_t data_size = sizeof(StackReference<mirror::Object>) * num_references;
+    size_t sirt_size = header_size + data_size;
+    return RoundUp(sirt_size, 8);
+  }
+
   // Link to previous SIRT or NULL.
   StackIndirectReferenceTable* GetLink() const {
     return link_;