Mercurial > hg > truffle
annotate test/runtime/InitialThreadOverflow/invoke.cxx @ 20218:828056cf311f
8040792: G1: Memory usage calculation uses sizeof(this) instead of sizeof(classname)
Summary: A few locations in the code use sizeof(this) which returns the size of the pointer instead of sizeof(classname) which returns the size of the sum of its members. This change fixes these errors and adds a few tests.
Reviewed-by: mgerdin, brutisso
author | tschatzl |
---|---|
date | Mon, 21 Jul 2014 09:40:19 +0200 |
parents | d8e99408faad |
children |
rev | line source |
---|---|
12144
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
1 /* |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
4 * |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
8 * |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
13 * accompanied this code). |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
14 * |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
18 * |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
21 * questions. |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
22 */ |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
23 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
24 #include <assert.h> |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
25 #include <jni.h> |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
26 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
27 #include <pthread.h> |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
28 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
29 JavaVM* jvm; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
30 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
31 void * |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
32 floobydust (void *p) { |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
33 JNIEnv *env; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
34 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
35 jvm->AttachCurrentThread((void**)&env, NULL); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
36 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
37 jclass class_id = env->FindClass ("DoOverflow"); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
38 assert (class_id); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
39 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
40 jmethodID method_id = env->GetStaticMethodID(class_id, "printIt", "()V"); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
41 assert (method_id); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
42 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
43 env->CallStaticVoidMethod(class_id, method_id, NULL); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
44 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
45 jvm->DetachCurrentThread(); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
46 } |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
47 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
48 int |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
49 main (int argc, const char** argv) { |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
50 JavaVMOption options[1]; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
51 options[0].optionString = (char*) "-Xss320k"; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
52 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
53 JavaVMInitArgs vm_args; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
54 vm_args.version = JNI_VERSION_1_2; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
55 vm_args.ignoreUnrecognized = JNI_TRUE; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
56 vm_args.options = options; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
57 vm_args.nOptions = 1; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
58 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
59 JNIEnv* env; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
60 jint result = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
61 assert(result >= 0); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
62 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
63 pthread_t thr; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
64 pthread_create(&thr, NULL, floobydust, NULL); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
65 pthread_join(thr, NULL); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
66 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
67 floobydust(NULL); |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
68 |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
69 return 0; |
d8e99408faad
8009062: poor performance of JNI AttachCurrentThread after fix for 7017193
dsamersoff
parents:
diff
changeset
|
70 } |