Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] more robust JS preprocessor #7105

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion emscripten.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,13 @@ def read_proxied_function_signatures(asmConsts):


def compile_settings(compiler_engine, libraries, temp_files):
settings = shared.Settings.to_dict()
settings.update((key, int(value)) for key, value in settings.items() if isinstance(value, bool))

# Save settings to a file to work around v8 issue 1579
with temp_files.get_file('.txt') as settings_file:
with open(settings_file, 'w') as s:
json.dump(shared.Settings.to_dict(), s, sort_keys=True)
json.dump(settings, s, sort_keys=True)

# Call js compiler
env = os.environ.copy()
Expand Down
4 changes: 0 additions & 4 deletions src/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ EXPORTED_FUNCTIONS = set(EXPORTED_FUNCTIONS);
EXCEPTION_CATCHING_WHITELIST = set(EXCEPTION_CATCHING_WHITELIST);
IMPLEMENTED_FUNCTIONS = set(IMPLEMENTED_FUNCTIONS);

// TODO: Implement support for proper preprocessing, e.g. "#if A || B" and "#if defined(A) || defined(B)" to
// avoid needing this here.
USES_GL_EMULATION = FULL_ES2 || LEGACY_GL_EMULATION;

DEAD_FUNCTIONS.forEach(function(dead) {
DEFAULT_LIBRARY_FUNCS_TO_INCLUDE.push(dead.substr(1));
});
Expand Down
2 changes: 1 addition & 1 deletion src/library_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ var LibraryBrowser = {

// Signal GL rendering layer that processing of a new frame is about to start. This helps it optimize
// VBO double-buffering and reduce GPU stalls.
#if USES_GL_EMULATION
#if FULL_ES2 || LEGACY_GL_EMULATION
GL.newRenderingFrameStarted();
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/library_fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// University of Illinois/NCSA Open Source License. Both these licenses can be
// found in the LICENSE file.

#include Fetch.js
#include "Fetch.js"

var LibraryFetch = {
#if USE_PTHREADS
Expand Down
10 changes: 5 additions & 5 deletions src/library_gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var LibraryGL = {
syncs: [],
#endif

#if USES_GL_EMULATION
#if FULL_ES2 || LEGACY_GL_EMULATION
currArrayBuffer: 0,
currElementArrayBuffer: 0,
#endif
Expand Down Expand Up @@ -77,7 +77,7 @@ var LibraryGL = {
unpackAlignment: 4, // default alignment is 4 bytes

init: function() {
#if USES_GL_EMULATION
#if FULL_ES2 || LEGACY_GL_EMULATION
GL.createLog2ceilLookup(GL.MAX_TEMP_BUFFER_SIZE);
#endif
GL.miniTempBuffer = new Float32Array(GL.MINI_TEMP_BUFFER_SIZE);
Expand Down Expand Up @@ -113,7 +113,7 @@ var LibraryGL = {
miniTempBuffer: null,
miniTempBufferViews: [0], // index i has the view of size i+1

#if USES_GL_EMULATION
#if FULL_ES2 || LEGACY_GL_EMULATION
// When user GL code wants to render from client-side memory, we need to upload the vertex data to a temp VBO
// for rendering. Maintain a set of temp VBOs that are created-on-demand to appropriate sizes, and never destroyed.
// Also, for best performance the VBOs are double-buffered, i.e. every second frame we switch the set of VBOs we
Expand Down Expand Up @@ -3642,7 +3642,7 @@ var LibraryGL = {
#endif
var bufferObj = buffer ? GL.buffers[buffer] : null;

#if USES_GL_EMULATION
#if FULL_ES2 || LEGACY_GL_EMULATION
if (target == GLctx.ARRAY_BUFFER) {
GL.currArrayBuffer = buffer;
#if LEGACY_GL_EMULATION
Expand Down Expand Up @@ -4282,7 +4282,7 @@ var LibraryGL = {
#endif
GLctx['bindVertexArray'](GL.vaos[vao]);
#endif
#if USES_GL_EMULATION
#if FULL_ES2 || LEGACY_GL_EMULATION
var ibo = GLctx.getParameter(GLctx.ELEMENT_ARRAY_BUFFER_BINDING);
GL.currElementArrayBuffer = ibo ? (ibo.name | 0) : 0;
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/library_idbstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var LibraryIDBStore = {
// just store large files, with almost no extra code; or you could implement a file b-tree using posix-compliant
// filesystem on top.
$IDBStore:
#include IDBStore.js
#include "IDBStore.js"
,

emscripten_idb_async_load: function(db, id, arg, onload, onerror) {
Expand Down
2 changes: 1 addition & 1 deletion src/library_sockfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ mergeInto(LibraryManager.library, {
if (ENVIRONMENT_IS_NODE) {
#if ENVIRONMENT_MAY_BE_NODE
WebSocketConstructor = require('ws');
#endif ENVIRONMENT_MAY_BE_NODE
#endif // ENVIRONMENT_MAY_BE_NODE
} else if (ENVIRONMENT_IS_WEB) {
#if ENVIRONMENT_MAY_BE_WEB
WebSocketConstructor = window['WebSocket'];
Expand Down
2 changes: 1 addition & 1 deletion src/library_vr.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ var LibraryWebVR = {
/* Prevent scheduler being called twice when loop is changed */
display.mainLoop.running = true;

#if USES_GL_EMULATION
#if FULL_ES2 || LEGACY_GL_EMULATION
GL.newRenderingFrameStarted();
#endif

Expand Down
Loading