diff --git a/src/duk_builtin_thread.c b/src/duk_builtin_thread.c index fa293821..3dbabc7f 100644 --- a/src/duk_builtin_thread.c +++ b/src/duk_builtin_thread.c @@ -285,15 +285,3 @@ int duk_builtin_thread_current(duk_context *ctx) { return 1; } -/* - * toString(), valueOf() - */ - -int duk_builtin_thread_prototype_to_string(duk_context *ctx) { - return DUK_RET_UNIMPLEMENTED_ERROR; -} - -int duk_builtin_thread_prototype_value_of(duk_context *ctx) { - return DUK_RET_UNIMPLEMENTED_ERROR; -} - diff --git a/src/duk_heap_alloc.c b/src/duk_heap_alloc.c index e5e594fd..1bf231c3 100644 --- a/src/duk_heap_alloc.c +++ b/src/duk_heap_alloc.c @@ -285,7 +285,7 @@ static int init_heap_thread(duk_heap *heap) { thr = duk_hthread_alloc(heap, DUK_HOBJECT_FLAG_EXTENSIBLE | DUK_HOBJECT_FLAG_THREAD | - DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT)); + DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_THREAD)); if (!thr) { DUK_DPRINT("failed to alloc heap_thread"); return 0; @@ -305,6 +305,9 @@ static int init_heap_thread(duk_heap *heap) { /* FIXME: this may now fail, and is not handled correctly */ duk_hthread_create_builtin_objects(thr); + /* default prototype (Note: 'thr' must be reachable) */ + DUK_HOBJECT_SET_PROTOTYPE(thr, (duk_hobject *) thr, thr->builtins[DUK_BIDX_THREAD_PROTOTYPE]); + return 1; } diff --git a/src/genbuiltins.py b/src/genbuiltins.py index 799abb95..cea679e9 100644 --- a/src/genbuiltins.py +++ b/src/genbuiltins.py @@ -1074,8 +1074,7 @@ bi_thread_prototype = { 'values': [ ], 'functions': [ - { 'name': 'toString', 'native': 'duk_builtin_thread_prototype_to_string', 'length': 0 }, - { 'name': 'valueOf', 'native': 'duk_builtin_thread_prototype_value_of', 'length': 0 }, + # toString() and valueOf() are inherited from Object.prototype ], }