@@ -626,8 +626,7 @@ typedef struct JSFunctionBytecode {
626
626
uint8_t super_allowed : 1;
627
627
uint8_t arguments_allowed : 1;
628
628
uint8_t backtrace_barrier : 1; /* stop backtrace on this function */
629
- uint8_t read_only_bytecode : 1;
630
- /* XXX: 4 bits available */
629
+ /* XXX: 5 bits available */
631
630
uint8_t *byte_code_buf; /* (self pointer) */
632
631
int byte_code_len;
633
632
JSAtom func_name;
@@ -5770,7 +5769,7 @@ static void compute_bytecode_size(JSFunctionBytecode *b, JSMemoryUsage_helper *h
5770
5769
if (b->closure_var) {
5771
5770
js_func_size += b->closure_var_count * sizeof(*b->closure_var);
5772
5771
}
5773
- if (!b->read_only_bytecode && b->byte_code_buf) {
5772
+ if (b->byte_code_buf) {
5774
5773
hp->js_func_code_size += b->byte_code_len;
5775
5774
}
5776
5775
memory_used_count++;
@@ -32117,7 +32116,7 @@ typedef enum BCTagEnum {
32117
32116
BC_TAG_OBJECT_REFERENCE,
32118
32117
} BCTagEnum;
32119
32118
32120
- #define BC_VERSION 6
32119
+ #define BC_VERSION 7
32121
32120
32122
32121
typedef struct BCWriterState {
32123
32122
JSContext *ctx;
@@ -32981,7 +32980,6 @@ typedef struct BCReaderState {
32981
32980
int error_state;
32982
32981
BOOL allow_sab : 8;
32983
32982
BOOL allow_bytecode : 8;
32984
- BOOL is_rom_data : 8;
32985
32983
BOOL allow_reference : 8;
32986
32984
/* object references */
32987
32985
JSObject **objects;
@@ -33213,17 +33211,9 @@ static int JS_ReadFunctionBytecode(BCReaderState *s, JSFunctionBytecode *b,
33213
33211
JSAtom atom;
33214
33212
uint32_t idx;
33215
33213
33216
- if (s->is_rom_data) {
33217
- /* directly use the input buffer */
33218
- if (unlikely(s->buf_end - s->ptr < bc_len))
33219
- return bc_read_error_end(s);
33220
- bc_buf = (uint8_t *)s->ptr;
33221
- s->ptr += bc_len;
33222
- } else {
33223
- bc_buf = (void *)((uint8_t*)b + byte_code_offset);
33224
- if (bc_get_buf(s, bc_buf, bc_len))
33225
- return -1;
33226
- }
33214
+ bc_buf = (uint8_t*)b + byte_code_offset;
33215
+ if (bc_get_buf(s, bc_buf, bc_len))
33216
+ return -1;
33227
33217
b->byte_code_buf = bc_buf;
33228
33218
33229
33219
pos = 0;
@@ -33237,20 +33227,15 @@ static int JS_ReadFunctionBytecode(BCReaderState *s, JSFunctionBytecode *b,
33237
33227
case OP_FMT_atom_label_u8:
33238
33228
case OP_FMT_atom_label_u16:
33239
33229
idx = get_u32(bc_buf + pos + 1);
33240
- if (s->is_rom_data) {
33241
- /* just increment the reference count of the atom */
33242
- JS_DupAtom(s->ctx, (JSAtom)idx);
33243
- } else {
33244
- if (bc_idx_to_atom(s, &atom, idx)) {
33245
- /* Note: the atoms will be freed up to this position */
33246
- b->byte_code_len = pos;
33247
- return -1;
33248
- }
33249
- put_u32(bc_buf + pos + 1, atom);
33230
+ if (bc_idx_to_atom(s, &atom, idx)) {
33231
+ /* Note: the atoms will be freed up to this position */
33232
+ b->byte_code_len = pos;
33233
+ return -1;
33234
+ }
33235
+ put_u32(bc_buf + pos + 1, atom);
33250
33236
#ifdef DUMP_READ_OBJECT
33251
- bc_read_trace(s, "at %d, fixup atom: ", pos + 1); print_atom(s->ctx, atom); printf("\n");
33237
+ bc_read_trace(s, "at %d, fixup atom: ", pos + 1); print_atom(s->ctx, atom); printf("\n");
33252
33238
#endif
33253
- }
33254
33239
break;
33255
33240
default:
33256
33241
break;
@@ -33394,7 +33379,6 @@ static JSValue JS_ReadFunctionTag(BCReaderState *s)
33394
33379
bc.super_allowed = bc_get_flags(v16, &idx, 1);
33395
33380
bc.arguments_allowed = bc_get_flags(v16, &idx, 1);
33396
33381
bc.backtrace_barrier = bc_get_flags(v16, &idx, 1);
33397
- bc.read_only_bytecode = s->is_rom_data;
33398
33382
if (bc_get_u8(s, &v8))
33399
33383
goto fail;
33400
33384
bc.js_mode = v8;
@@ -33425,9 +33409,7 @@ static JSValue JS_ReadFunctionTag(BCReaderState *s)
33425
33409
closure_var_offset = function_size;
33426
33410
function_size += bc.closure_var_count * sizeof(*bc.closure_var);
33427
33411
byte_code_offset = function_size;
33428
- if (!bc.read_only_bytecode) {
33429
- function_size += bc.byte_code_len;
33430
- }
33412
+ function_size += bc.byte_code_len;
33431
33413
33432
33414
b = js_mallocz(ctx, function_size);
33433
33415
if (!b)
@@ -34071,8 +34053,6 @@ static int JS_ReadObjectAtoms(BCReaderState *s)
34071
34053
if (atom == JS_ATOM_NULL)
34072
34054
return s->error_state = -1;
34073
34055
s->idx_to_atom[i] = atom;
34074
- if (s->is_rom_data && (atom != (i + s->first_atom)))
34075
- s->is_rom_data = FALSE; /* atoms must be relocated */
34076
34056
}
34077
34057
bc_read_trace(s, "}\n");
34078
34058
return 0;
@@ -34105,7 +34085,6 @@ JSValue JS_ReadObject(JSContext *ctx, const uint8_t *buf, size_t buf_len,
34105
34085
s->buf_end = buf + buf_len;
34106
34086
s->ptr = buf;
34107
34087
s->allow_bytecode = ((flags & JS_READ_OBJ_BYTECODE) != 0);
34108
- s->is_rom_data = ((flags & JS_READ_OBJ_ROM_DATA) != 0);
34109
34088
s->allow_sab = ((flags & JS_READ_OBJ_SAB) != 0);
34110
34089
s->allow_reference = ((flags & JS_READ_OBJ_REFERENCE) != 0);
34111
34090
if (s->allow_bytecode)
0 commit comments