blob: 073de22f15d68e20b6875da34ca9b773636e5be3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
*/
#include "config.h"
#include "JavaEnv.h"
JavaVM* jvm = 0;
JNIEnv* JNICALL DumpRenderTree_GetJavaEnv()
{
void* env;
jvm->GetEnv(&env, JNI_VERSION_1_2);
return (JNIEnv*)env;
}
bool CheckAndClearException(JNIEnv* env)
{
if (JNI_TRUE == env->ExceptionCheck()) {
env->ExceptionDescribe();
env->ExceptionClear();
return true;
}
return false;
}
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
jvm = vm;
return JNI_VERSION_1_2;
}
JNIEXPORT void JNICALL JNI_OnUnLoad(JavaVM* vm, void* reserved)
{
jvm = 0;
}
#if OS(WINDOWS)
#include <Windows.h>
#include <math.h>
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH) {
#if defined(_MSC_VER) && _MSC_VER >= 1800 && _MSC_VER < 1900 && defined(_M_X64) || defined(__x86_64__)
// The VS2013 runtime has a bug where it mis-detects AVX-capable processors
// if the feature has been disabled in firmware. This causes us to crash
// in some of the math functions. For now, we disable those optimizations
// because Microsoft is not going to fix the problem in VS2013.
// FIXME: Remove this workaround when we switch to VS2015+.
_set_FMA3_enable(0);
#endif
}
return TRUE;
}
#endif
#ifdef __cplusplus
}
#endif
|