File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -96,17 +96,21 @@ public void duringSetup(DuringSetupAccess access) {
9696 @ Override
9797 public void beforeCompilation (BeforeCompilationAccess access ) {
9898 ObjectLayout layout = ConfigurationValues .getObjectLayout ();
99- int nextIndex = 0 ;
99+ int alignment = layout .getAlignment ();
100+
101+ int baseOffset = layout .getArrayBaseOffset (JavaKind .Byte );
102+ /* padding if first element is not object aligned */
103+ int nextIndex = NumUtil .roundUp (baseOffset , alignment ) - baseOffset ;
100104
101105 PthreadVMMutex [] mutexes = mutexReplacer .getReplacements ().toArray (new PthreadVMMutex [0 ]);
102- int mutexSize = NumUtil .roundUp (SizeOf .get (Pthread .pthread_mutex_t .class ), 8 );
106+ int mutexSize = NumUtil .roundUp (SizeOf .get (Pthread .pthread_mutex_t .class ), alignment );
103107 for (PthreadVMMutex mutex : mutexes ) {
104108 mutex .structOffset = WordFactory .unsigned (layout .getArrayElementOffset (JavaKind .Byte , nextIndex ));
105109 nextIndex += mutexSize ;
106110 }
107111
108112 PthreadVMCondition [] conditions = conditionReplacer .getReplacements ().toArray (new PthreadVMCondition [0 ]);
109- int conditionSize = NumUtil .roundUp (SizeOf .get (Pthread .pthread_cond_t .class ), 8 );
113+ int conditionSize = NumUtil .roundUp (SizeOf .get (Pthread .pthread_cond_t .class ), alignment );
110114 for (PthreadVMCondition condition : conditions ) {
111115 condition .structOffset = WordFactory .unsigned (layout .getArrayElementOffset (JavaKind .Byte , nextIndex ));
112116 nextIndex += conditionSize ;
You can’t perform that action at this time.
0 commit comments