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