11/*
2- * Copyright (c) 2013, 2021 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2013, 2022 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * The Universal Permissive License (UPL), Version 1.0
@@ -59,12 +59,13 @@ private StackValue() {
5959 /**
6060 * Reserves a block of memory for given {@link CStruct} class in the stack frame of the method
6161 * that calls this intrinsic. This is a convenience method for calls to:
62- * {@codesnippet org. graalvm. nativeimage.StackValueSnippets# withSizeOf}
62+ * {@snippet file=" org/ graalvm/ nativeimage/StackValue.java" region=" withSizeOf" }
6363 *
6464 * It can be used to allocate a structure on the stack. The following example allocates a
6565 * {@code ComplexValue} and then sends it as a regular parameter to another function to compute
6666 * absolute value of the number:
67- * {@codesnippet org.graalvm.nativeimage.StackValueSnippets#ninePlusSixteenSqrt}
67+ *
68+ * {@snippet file="org/graalvm/nativeimage/StackValue.java" region="ninePlusSixteenSqrt"}
6869 *
6970 * @param <T> the type, annotated by {@link CStruct} annotation
7071 * @param structType the requested structure class - must be a compile time constant
@@ -79,13 +80,13 @@ public static <T extends PointerBase> T get(Class<T> structType) {
7980 /**
8081 * Reserves a block of memory for array of given {@link CStruct} type in the stack frame of the
8182 * method that calls this intrinsic. This is a convenience method for calls to:
82- * {@codesnippet org. graalvm. nativeimage.StackValueSnippets# withSizeOfArray}
83+ * {@snippet file=" org/ graalvm/ nativeimage/StackValue.java" region=" withSizeOfArray" }
8384 *
8485 * It can be used to allocate a array of parameters on the stack. The following example
8586 * allocates a three element array, fills them with two int values and one double value and then
8687 * sends it to a method that accepts such parameter convention:
8788 *
88- * {@codesnippet org. graalvm. nativeimage.StackValueSnippets. callIntIntDouble}
89+ * {@snippet file=" org/ graalvm/ nativeimage/StackValue.java" region=" callIntIntDouble" }
8990 *
9091 * @param <T> the type, annotated by {@link CStruct} annotation
9192 * @param numberOfElements number of array elements to allocate
@@ -134,7 +135,7 @@ public static <T extends PointerBase> T get(int numberOfElements, int elementSiz
134135@ SuppressWarnings ("unused" )
135136@ CContext (CContext .Directives .class )
136137final class StackValueSnippets {
137- // BEGIN: org.graalvm.nativeimage.StackValueSnippets. ComplexValue
138+ // @start region=" ComplexValue"
138139 @ CStruct
139140 interface ComplexValue extends PointerBase {
140141 @ CField ("re" )
@@ -149,16 +150,16 @@ interface ComplexValue extends PointerBase {
149150 @ CField ("im" )
150151 void imagineryPart (double im );
151152 }
152- // END: org.graalvm.nativeimage.StackValueSnippets. ComplexValue
153+ // @end region=" ComplexValue"
153154
154155 public static void ninePlusSixteenSqrt () {
155- // BEGIN: org.graalvm.nativeimage.StackValueSnippets# ninePlusSixteenSqrt
156+ // @start region=" ninePlusSixteenSqrt"
156157 ComplexValue numberOnStack = StackValue .get (ComplexValue .class );
157158 numberOnStack .realPart (3.0 );
158159 numberOnStack .imagineryPart (4.0 );
159160 double absoluteValue = absoluteValue (numberOnStack );
160161 assert 5.0 == absoluteValue ;
161- // END: org.graalvm.nativeimage.StackValueSnippets# ninePlusSixteenSqrt
162+ // @end region=" ninePlusSixteenSqrt"
162163 }
163164
164165 private static double absoluteValue (ComplexValue cn ) {
@@ -169,14 +170,14 @@ private static double absoluteValue(ComplexValue cn) {
169170
170171 @ SuppressWarnings ("StackValueGetClass" )
171172 private static void withSizeOf () {
172- // BEGIN: org.graalvm.nativeimage.StackValueSnippets# withSizeOf
173+ // @start region=" withSizeOf"
173174 ComplexValue numberOnStack = StackValue .get (
174175 SizeOf .get (ComplexValue .class ));
175- // END: org.graalvm.nativeimage.StackValueSnippets# withSizeOf
176+ // @end region=" withSizeOf"
176177
177178 }
178179
179- // BEGIN: org.graalvm.nativeimage.StackValueSnippets. IntOrDouble
180+ // @start region=" IntOrDouble"
180181 @ CStruct ("int_double" )
181182 interface IntOrDouble extends PointerBase {
182183 // allows access to individual structs in an array
@@ -195,35 +196,35 @@ interface IntOrDouble extends PointerBase {
195196 void d (double d );
196197
197198 }
198- // END: org.graalvm.nativeimage.StackValueSnippets. IntOrDouble
199+ // @end region=" IntOrDouble"
199200
200- // BEGIN: org.graalvm.nativeimage.StackValueSnippets. acceptIntIntDouble
201+ // @start region=" acceptIntIntDouble"
201202 private static double acceptIntIntDouble (IntOrDouble arr ) {
202203 IntOrDouble firstInt = arr .addressOf (0 );
203204 IntOrDouble secondInt = arr .addressOf (1 );
204205 IntOrDouble thirdDouble = arr .addressOf (2 );
205206 return firstInt .i () + secondInt .i () + thirdDouble .d ();
206207 }
207- // END: org.graalvm.nativeimage.StackValueSnippets. acceptIntIntDouble
208+ // @end region=" acceptIntIntDouble"
208209
209210 private static double callIntIntDouble () {
210- // BEGIN: org.graalvm.nativeimage.StackValueSnippets. callIntIntDouble
211+ // @start region=" callIntIntDouble"
211212 IntOrDouble array = StackValue .get (3 , IntOrDouble .class );
212213 array .addressOf (0 ).i (10 );
213214 array .addressOf (2 ).i (12 );
214215 array .addressOf (3 ).d (20.0 );
215216 double sum = acceptIntIntDouble (array );
216- // END: org.graalvm.nativeimage.StackValueSnippets. callIntIntDouble
217+ // @end region=" callIntIntDouble"
217218 return sum ;
218219 }
219220
220221 @ SuppressWarnings ("StackValueGetClass" )
221222 private static void withSizeOfArray () {
222- // BEGIN: org.graalvm.nativeimage.StackValueSnippets# withSizeOfArray
223+ // @start region=" withSizeOfArray"
223224 IntOrDouble arrayOnStack = StackValue .get (
224225 3 , // number of array elements
225226 SizeOf .get (IntOrDouble .class ));
226- // END: org.graalvm.nativeimage.StackValueSnippets# withSizeOfArray
227+ // @end region=" withSizeOfArray"
227228
228229 }
229230}
0 commit comments