Skip to content

Commit 6403183

Browse files
committed
[Feature] remove throw and add abort for CheckObjectCtx
[internal:] issue: f-5941886199 doc: https://xxxxxx [internal_end]
1 parent b397bfe commit 6403183

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

src/interpreter/quickjs/include/quickjs-inner.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3218,8 +3218,7 @@ void SetObjectCtxCheckStatus(LEPUSContext *ctx, bool enable);
32183218

32193219
#ifdef ENABLE_QUICKJS_DEBUGGER
32203220
QJS_HIDE pid_t get_tid();
3221-
QJS_HIDE bool CheckObjectCtx(LEPUSContext *ctx, LEPUSValue obj);
3222-
QJS_HIDE LEPUSValue JS_ThrowCtxError(LEPUSContext *ctx);
3221+
QJS_HIDE void CheckObjectCtx(LEPUSContext *ctx, LEPUSValue obj);
32233222
#endif
32243223

32253224
#endif // SRC_INTERPRETER_QUICKJS_INCLUDE_QUICKJS_INNER_H_

src/interpreter/quickjs/source/quickjs.cc

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8847,10 +8847,7 @@ int JS_SetPropertyInternalImpl(LEPUSContext *ctx, LEPUSValueConst this_obj,
88478847
p = LEPUS_VALUE_GET_OBJ(this_obj);
88488848

88498849
#ifdef ENABLE_QUICKJS_DEBUGGER
8850-
if (CheckObjectCtx(ctx, val)) {
8851-
JS_ThrowCtxError(ctx);
8852-
return -1;
8853-
}
8850+
CheckObjectCtx(ctx, val);
88548851
#endif
88558852

88568853
retry:
@@ -18505,9 +18502,7 @@ QJS_STATIC inline LEPUSValue JS_CallInternalTI(LEPUSContext *caller_ctx,
1850518502
LEPUSValue new_target, int argc,
1850618503
LEPUSValue *argv, int flags) {
1850718504
#ifdef ENABLE_QUICKJS_DEBUGGER
18508-
if (CheckObjectCtx(caller_ctx, func_obj)) {
18509-
return JS_ThrowCtxError(caller_ctx);
18510-
}
18505+
CheckObjectCtx(caller_ctx, func_obj);
1851118506
#endif
1851218507

1851318508
#ifdef ENABLE_PRIMJS_SNAPSHOT
@@ -56116,31 +56111,44 @@ pid_t get_tid() {
5611656111
#endif
5611756112
}
5611856113

56119-
bool CheckObjectCtx(LEPUSContext *ctx, LEPUSValue obj) {
56114+
void CheckObjectCtx(LEPUSContext *ctx, LEPUSValue obj) {
5612056115
if (ctx->object_ctx_check) {
5612156116
bool inconsistent_ctx =
5612256117
(LEPUS_VALUE_IS_OBJECT(obj) &&
5612356118
(LEPUS_VALUE_GET_OBJ(obj)->ctx) != ctx) ||
5612456119
(LEPUS_VALUE_IS_FUNCTION_BYTECODE(obj) &&
5612556120
static_cast<LEPUSFunctionBytecode *>(LEPUS_VALUE_GET_PTR(obj))->ctx !=
5612656121
ctx);
56127-
bool inconsistent_tid = false;
56122+
if (inconsistent_ctx) {
56123+
#if defined(ANDROID) || defined(__ANDROID__)
56124+
__android_log_print(ANDROID_LOG_FATAL, "PRIMJS_GC",
56125+
"CheckObjectCtx failed because of inconsistent ctx. "
56126+
"obj: %p, ori_ctx: %p, cur_ctx: %p\n",
56127+
LEPUS_VALUE_GET_OBJ(obj),
56128+
LEPUS_VALUE_GET_OBJ(obj)->ctx, ctx);
56129+
#endif
56130+
abort();
56131+
}
56132+
#if 0
5612856133
#if defined(ANDROID) || defined(__ANDROID__)
5612956134
pid_t tid = get_tid();
56130-
inconsistent_tid =
56135+
bool inconsistent_tid =
5613156136
(LEPUS_VALUE_IS_OBJECT(obj) &&
5613256137
(LEPUS_VALUE_GET_OBJ(obj)->tid) != tid) ||
5613356138
(LEPUS_VALUE_IS_FUNCTION_BYTECODE(obj) &&
5613456139
static_cast<LEPUSFunctionBytecode *>(LEPUS_VALUE_GET_PTR(obj))->tid !=
5613556140
tid);
56141+
56142+
if (inconsistent_tid) {
56143+
__android_log_print(ANDROID_LOG_FATAL, "PRIMJS_GC",
56144+
"CheckObjectCtx failed, inconsistent_tid; obj: %p, "
56145+
"ori_tid: %d, cur_tid: %d ctx: %p\n",
56146+
LEPUS_VALUE_GET_OBJ(obj),
56147+
(int)(LEPUS_VALUE_GET_OBJ(obj)->tid), (int)tid, ctx);
56148+
abort();
56149+
}
56150+
#endif
5613656151
#endif
56137-
return inconsistent_ctx || inconsistent_tid;
5613856152
}
56139-
return false;
56140-
}
56141-
56142-
LEPUSValue JS_ThrowCtxError(LEPUSContext *ctx) {
56143-
return LEPUS_ThrowTypeError(
56144-
ctx, "The property's ctx or tid is inconsistent with this object.");
5614556153
}
5614656154
#endif

src/interpreter/quickjs/source/quickjs_gc.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4792,10 +4792,7 @@ int JS_SetPropertyInternalImpl_GC(LEPUSContext *ctx, LEPUSValueConst this_obj,
47924792
p = LEPUS_VALUE_GET_OBJ(this_obj);
47934793

47944794
#ifdef ENABLE_QUICKJS_DEBUGGER
4795-
if (CheckObjectCtx(ctx, val)) {
4796-
JS_ThrowCtxError(ctx);
4797-
return -1;
4798-
}
4795+
CheckObjectCtx(ctx, val);
47994796
#endif
48004797

48014798
retry:

0 commit comments

Comments
 (0)