Skip to content

Commit 20951db

Browse files
committed
Using thread_local for all builds
See discussion at: emscripten-core/emscripten#22772
1 parent fa0df81 commit 20951db

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ if (ENABLE_MULTI_THREADING)
5959
-s PTHREAD_POOL_SIZE=16)
6060
set(CMAKE_CXX_FLAGS "-pthread -s SHARED_MEMORY")
6161
set(OUTPUT_BASE_NAME "${OUTPUT_FOLDER}jolt-physics.multithread")
62-
set(WEBIDL_PARAMS "--thread_safe")
6362
else()
6463
set(MULTI_THREADED_FLAG "")
6564
set(ENVIRONMENT_FLAG "-s ENVIRONMENT='web,node'")
6665
set(OUTPUT_BASE_NAME "${OUTPUT_FOLDER}jolt-physics")
67-
set(WEBIDL_PARAMS "")
6866
endif()
6967

7068
# Enable SIMD flags
@@ -201,7 +199,7 @@ add_custom_command(
201199
OUTPUT glue.cpp glue.js jolt.idl
202200
BYPRODUCTS parser.out WebIDLGrammar.pkl
203201
COMMAND cat ${JOLT_IDL_FILE} > jolt.idl
204-
COMMAND ${PYTHON} ${WEBIDL_BINDER_SCRIPT} jolt.idl glue ${WEBIDL_PARAMS}
202+
COMMAND ${PYTHON} ${WEBIDL_BINDER_SCRIPT} jolt.idl glue
205203
DEPENDS ${JOLT_IDL_FILE}
206204
COMMENT "Generating JoltPhysics.js bindings"
207205
VERBATIM)

tools/webidl_binder.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ def getExtendedAttribute(self, _name):
5959
parser = argparse.ArgumentParser()
6060
parser.add_argument('--wasm64', action='store_true', default=False,
6161
help='Build for wasm64')
62-
parser.add_argument('--thread_safe', action='store_true', default=False,
63-
help='Emit temporaries as "static thread_local" to avoid race conditions')
6462
parser.add_argument('infile')
6563
parser.add_argument('outfile')
6664
options = parser.parse_args()
@@ -390,7 +388,7 @@ def type_to_cdec(raw):
390388

391389
def render_function(class_name, func_name, sigs, return_type, non_pointer,
392390
copy, operator, constructor, is_static, func_scope,
393-
call_content=None, const=False, array_attribute=False, thread_safe=False):
391+
call_content=None, const=False, array_attribute=False):
394392
legacy_mode = CHECKS not in ['ALL', 'FAST']
395393
all_checks = CHECKS == 'ALL'
396394

@@ -626,13 +624,10 @@ def make_call_args(i):
626624
basic_return = 'return ' if constructor or return_type != 'Void' else ''
627625
return_prefix = basic_return
628626
return_postfix = ''
629-
storage_attribute = ''
630627
if non_pointer:
631628
return_prefix += '&'
632-
if thread_safe:
633-
storage_attribute = 'thread_local '
634629
if copy:
635-
pre += ' static %s%s temp;\n' % (storage_attribute, type_to_c(return_type, non_pointing=True))
630+
pre += ' static thread_local %s temp;\n' % type_to_c(return_type, non_pointing=True)
636631
return_prefix += '(temp = '
637632
return_postfix += ', &temp)'
638633

@@ -770,8 +765,7 @@ def add_bounds_check_impl():
770765
constructor,
771766
is_static=m.isStatic(),
772767
func_scope=m.parentScope.identifier.name,
773-
const=m.getExtendedAttribute('Const'),
774-
thread_safe=options.thread_safe)
768+
const=m.getExtendedAttribute('Const'))
775769
mid_js += ['\n']
776770
if constructor:
777771
mid_js += build_constructor(name)
@@ -813,8 +807,7 @@ def add_bounds_check_impl():
813807
func_scope=interface,
814808
call_content=get_call_content,
815809
const=m.getExtendedAttribute('Const'),
816-
array_attribute=m.type.isArray(),
817-
thread_safe=options.thread_safe)
810+
array_attribute=m.type.isArray())
818811

819812
if m.readonly:
820813
mid_js += [r'''
@@ -836,8 +829,7 @@ def add_bounds_check_impl():
836829
func_scope=interface,
837830
call_content=set_call_content,
838831
const=m.getExtendedAttribute('Const'),
839-
array_attribute=m.type.isArray(),
840-
thread_safe=options.thread_safe)
832+
array_attribute=m.type.isArray())
841833
mid_js += [r'''
842834
/** @suppress {checkTypes} */
843835
Object.defineProperty(%s.prototype, '%s', { get: %s.prototype.%s, set: %s.prototype.%s });
@@ -855,8 +847,7 @@ def add_bounds_check_impl():
855847
False,
856848
False,
857849
func_scope=interface,
858-
call_content='delete self',
859-
thread_safe=options.thread_safe)
850+
call_content='delete self')
860851

861852
# Emit C++ class implementation that calls into JS implementation
862853

0 commit comments

Comments
 (0)