Browse Source

Merge pull request #1186 from svaarala/footprint-push-empty-string-fixed

Add internal duk_push_hstring_empty() helper
pull/1183/head
Sami Vaarala 8 years ago
committed by GitHub
parent
commit
157a57a2cd
  1. 3
      RELEASES.rst
  2. 1
      src-input/duk_api_internal.h
  3. 10
      src-input/duk_api_stack.c
  4. 2
      src-input/duk_api_string.c
  5. 2
      src-input/duk_bi_array.c
  6. 2
      src-input/duk_bi_function.c
  7. 2
      src-input/duk_bi_json.c
  8. 4
      src-input/duk_bi_regexp.c
  9. 2
      src-input/duk_bi_string.c
  10. 2
      src-input/duk_debugger.c
  11. 2
      src-input/duk_js_var.c

3
RELEASES.rst

@ -2252,7 +2252,8 @@ Planned
bytecode allocation in Ecmascript compiler for low memory targets (GH-1146);
packed arguments for some internal helper calls (GH-1158, GH-1172); misc
internal helpers to reduce call site size (GH-1166, GH-1173); config options
for function .name and .fileName control (GH-1153)
for function .name and .fileName control (GH-1153); internal helper
duk_push_hstring_empty() (GH-1186)
* Internal change: rework shared internal string handling so that shared
strings are plain string constants used in macro values, rather than

1
src-input/duk_api_internal.h

@ -151,6 +151,7 @@ DUK_INTERNAL_DECL duk_hobject *duk_require_hobject_with_class(duk_context *ctx,
DUK_INTERNAL_DECL void duk_push_hstring(duk_context *ctx, duk_hstring *h);
DUK_INTERNAL_DECL void duk_push_hstring_stridx(duk_context *ctx, duk_small_uint_t stridx);
DUK_INTERNAL_DECL void duk_push_hstring_empty(duk_context *ctx);
DUK_INTERNAL_DECL void duk_push_hobject(duk_context *ctx, duk_hobject *h);
DUK_INTERNAL_DECL void duk_push_hbuffer(duk_context *ctx, duk_hbuffer *h);
#define duk_push_hthread(ctx,h) \

10
src-input/duk_api_stack.c

@ -3641,8 +3641,8 @@ DUK_EXTERNAL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va
/* special handling of fmt==NULL */
if (!fmt) {
duk_hstring *h_str;
duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);
h_str = DUK_HTHREAD_STRING_EMPTY_STRING(thr); /* rely on interning, must be this string */
duk_push_hstring_empty(ctx);
h_str = duk_known_hstring(ctx, -1);
return (const char *) DUK_HSTRING_GET_DATA(h_str);
}
@ -4420,6 +4420,12 @@ DUK_INTERNAL void duk_push_hstring_stridx(duk_context *ctx, duk_small_uint_t str
duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));
}
DUK_INTERNAL void duk_push_hstring_empty(duk_context *ctx) {
duk_hthread *thr = (duk_hthread *) ctx;
DUK_UNREF(thr);
duk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, DUK_STRIDX_EMPTY_STRING));
}
DUK_INTERNAL void duk_push_hobject(duk_context *ctx, duk_hobject *h) {
duk_tval tv;
DUK_ASSERT_CTX_VALID(ctx);

2
src-input/duk_api_string.c

@ -21,7 +21,7 @@ DUK_LOCAL void duk__concat_and_join_helper(duk_context *ctx, duk_idx_t count_in,
return;
}
DUK_ASSERT(count_in == 0);
duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);
duk_push_hstring_empty(ctx);
return;
}
count = (duk_uint_t) count_in;

2
src-input/duk_bi_array.c

@ -379,7 +379,7 @@ DUK_INTERNAL duk_ret_t duk_bi_array_prototype_join_shared(duk_context *ctx) {
duk_get_prop_index(ctx, 1, (duk_uarridx_t) idx);
if (duk_is_null_or_undefined(ctx, -1)) {
duk_pop(ctx);
duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);
duk_push_hstring_empty(ctx);
} else {
if (to_locale_string) {
duk_to_object(ctx, -1);

2
src-input/duk_bi_function.c

@ -387,7 +387,7 @@ DUK_INTERNAL duk_ret_t duk_bi_function_prototype_bind(duk_context *ctx) {
* empty string. ES6 19.2.3.2.
*/
duk_pop(ctx);
duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);
duk_push_hstring_empty(ctx);
}
duk_concat(ctx, 2);
duk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C);

2
src-input/duk_bi_json.c

@ -3099,7 +3099,7 @@ void duk_bi_json_stringify_helper(duk_context *ctx,
/* serialize the wrapper with empty string key */
duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);
duk_push_hstring_empty(ctx);
/* [ ... buf loop (proplist) (gap) holder "" ] */

4
src-input/duk_bi_regexp.c

@ -56,12 +56,12 @@ DUK_INTERNAL duk_ret_t duk_bi_regexp_constructor(duk_context *ctx) {
}
} else {
if (duk_is_undefined(ctx, 0)) {
duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);
duk_push_hstring_empty(ctx);
} else {
duk_dup_0(ctx);
}
if (duk_is_undefined(ctx, 1)) {
duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);
duk_push_hstring_empty(ctx);
} else {
duk_dup_1(ctx);
}

2
src-input/duk_bi_string.c

@ -25,7 +25,7 @@ DUK_INTERNAL duk_ret_t duk_bi_string_constructor(duk_context *ctx) {
*/
if (duk_get_top(ctx) == 0) {
duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);
duk_push_hstring_empty(ctx);
} else {
duk_to_string(ctx, 0);
}

2
src-input/duk_debugger.c

@ -385,7 +385,7 @@ DUK_INTERNAL duk_hstring *duk_debug_read_hstring(duk_hthread *thr) {
fail:
DUK_D(DUK_DPRINT("debug connection error: failed to decode int"));
DUK__SET_CONN_BROKEN(thr, 1);
duk_push_hstring_stridx(thr, DUK_STRIDX_EMPTY_STRING); /* always push some string */
duk_push_hstring_empty(ctx); /* always push some string */
return duk_require_hstring(ctx, -1);
}

2
src-input/duk_js_var.c

@ -441,7 +441,7 @@ void duk_js_push_closure(duk_hthread *thr,
/* [ ... closure template undefined ] */
/* XXX: anonymous function name? empty string in e.g. V8 */
duk_pop(ctx);
duk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);
duk_push_hstring_empty(ctx);
}
duk_xdef_prop_stridx_short(ctx, -3, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C); /* -> [ ... closure template ] */
#endif

Loading…
Cancel
Save