Skip to content

Commit

Permalink
refactor: remove unused debug.c/h and rename convertion.c to conversi…
Browse files Browse the repository at this point in the history
…on.h
  • Loading branch information
shiqimei committed Jun 14, 2023
1 parent 5a1e3fa commit 5ce355e
Show file tree
Hide file tree
Showing 31 changed files with 38 additions and 96 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ local.properties
cmake-build-*
lib/
bin/
build/
build/
test262/
test262*.txt
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ sudo apt install lldb # Ubuntu

If you're using VSCode, you can use the `C/C++` and `Code LLDB` extension to debug.

Pass this argument to cmake enable debug log on release build.

```
-DCONFIG_DEBUG_ON_RELEASE=1
```

### Tests

```bash
Expand Down
5 changes: 0 additions & 5 deletions include/quickjs/quickjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -983,9 +983,4 @@ int JS_SetModuleExportList(JSContext* ctx, JSModuleDef* m, const JSCFunctionList
/* quickjs_rs c bindings */
#include "quickjs-rs.h"

/* Should use in `jsc` repl only */
#ifdef CONFIG_DEBUG_ON_RELEASE
void __internal_debug_log(const char* fmt, ...);
#endif

#endif /* QUICKJS_H */
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ cd test262
# patch -p1 < ../tests/test262.patch
cd ..
touch test262_errors.txt
./bin/run-test262 -m -c test262.conf -a
./bin/run-test262 -m -c tests/test262.conf -a
17 changes: 1 addition & 16 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ add_library(quickjs
core/malloc.c
core/shape.c
core/parser.c
core/convertion.c
core/conversion.c
core/runtime.c
core/module.c
core/ic.c
Expand All @@ -56,9 +56,6 @@ add_library(quickjs
core/builtins/js-string.c
core/builtins/js-symbol.c
core/builtins/js-typed-array.c

# misc
core/misc/debug.c
)

# create a custom target for including headers
Expand All @@ -75,18 +72,6 @@ set(QUICKJS_VERSION STRING "0.1.0")

add_compile_options(${COMPILE_FLAGS})

# Debug on release
if (CONFIG_DEBUG_ON_RELEASE)
add_compile_definitions(CONFIG_DEBUG_ON_RELEASE)
endif()

# Debug on release
if (CONFIG_DEBUG_ON_RELEASE)
target_compile_options(quickjs PUBLIC
-DCONFIG_DEBUG_ON_RELEASE
)
endif()

target_compile_options(quickjs PUBLIC
-D_GNU_SOURCE
-DCONFIG_BIGNUM
Expand Down
13 changes: 1 addition & 12 deletions src/core/builtins/js-array.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-array.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../object.h"
Expand Down Expand Up @@ -867,17 +867,6 @@ JSValue js_array_indexOf(JSContext* ctx, JSValueConst this_val, int argc, JSValu
if (present < 0)
goto exception;
if (present) {
#ifdef CONFIG_DEBUG_ON_RELEASE
__internal_debug_log(
"present_str: %s, input_char: %s, present: %d, char: %s, equal: %d",
JS_ToCString(ctx,this_val),
JS_ToCString(ctx,argv[0]),
present,
JS_ToCString(ctx, JS_DupValue(ctx, val)),
js_strict_eq2(ctx, JS_DupValue(ctx, argv[0]), val, JS_EQ_STRICT),
"\n"
);
#endif
if (js_strict_eq2(ctx, JS_DupValue(ctx, argv[0]), val, JS_EQ_STRICT)) {
res = n;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-atomics.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-atomics.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "js-typed-array.h"

Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-big-num.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-big-num.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../object.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-date.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-date.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../object.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-function.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-function.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../gc.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-json.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../object.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-number.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-number.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../object.h"
#include "../runtime.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-object.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../object.h"
#include "../runtime.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include "js-operator.h"

#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../object.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-promise.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-promise.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../object.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-proxy.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../object.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-regexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "quickjs/libregexp-opcode.h"
#include "quickjs/libregexp.h"

#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../object.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-string.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../object.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/builtins/js-typed-array.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "js-typed-array.h"
#include "../convertion.h"
#include "../conversion.h"
#include "../exception.h"
#include "../function.h"
#include "../object.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/convertion.c → src/core/conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* THE SOFTWARE.
*/

#include "convertion.h"
#include "conversion.h"
#include "builtins/js-big-num.h"
#include "exception.h"
#include "function.h"
Expand Down
4 changes: 2 additions & 2 deletions src/core/convertion.h → src/core/conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* THE SOFTWARE.
*/

#ifndef QUICKJS_CONVERTION_H
#define QUICKJS_CONVERTION_H
#ifndef QUICKJS_CONVERSION_H
#define QUICKJS_CONVERSION_H

#include "quickjs/quickjs.h"
#include "quickjs/cutils.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/function.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "builtins/js-object.h"
#include "builtins/js-operator.h"
#include "builtins/js-regexp.h"
#include "convertion.h"
#include "conversion.h"
#include "exception.h"
#include "gc.h"
#include "module.h"
Expand Down
15 changes: 0 additions & 15 deletions src/core/misc/debug.c

This file was deleted.

8 changes: 0 additions & 8 deletions src/core/misc/debug.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/core/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "builtins/js-object.h"
#include "builtins/js-operator.h"
#include "builtins/js-proxy.h"
#include "convertion.h"
#include "conversion.h"
#include "exception.h"
#include "function.h"
#include "gc.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "parser.h"
#include "builtins/js-function.h"
#include "convertion.h"
#include "conversion.h"
#include "exception.h"
#include "function.h"
#include "bytecode.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include "builtins/js-operator.h"
#include "builtins/js-reflect.h"
#include "builtins/js-symbol.h"
#include "convertion.h"
#include "conversion.h"
#include "gc.h"
#include "module.h"
#include "object.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

#include "string.h"
#include "convertion.h"
#include "conversion.h"
#include "exception.h"
#include "quickjs/cutils.h"
#include "quickjs/list.h"
Expand Down
12 changes: 6 additions & 6 deletions src/crates/quickjs_gc/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use std::sync::{Mutex, Once};
use quickjs_common::backtrace::Backtrace;
use crate::{JSGCObjectHeader, ListHead};

// Define a global static Once variable and a static mutable option of the Mutexed HashMap
/// Define a global static Once variable and a static mutable option of the Mutexed HashMap
static INIT: Once = Once::new();
static mut GC_OBJECTS: Option<Mutex<HashMap<*const JSGCObjectHeader, Backtrace>>> = None;

// Function to safely initialize and get a reference to the global
// HashMap storing garbage-collected objects and their backtraces.
/// Function to safely initialize and get a reference to the global
/// HashMap storing garbage-collected objects and their backtraces.
pub fn get_gc_object_backtrace_map() -> &'static Mutex<HashMap<*const JSGCObjectHeader, Backtrace>> {
unsafe {
INIT.call_once(|| {
Expand All @@ -19,9 +19,9 @@ pub fn get_gc_object_backtrace_map() -> &'static Mutex<HashMap<*const JSGCObject
}
}

// This function records the creation of a garbage-collected object.
// It takes a raw pointer to the object and stores it along with a
// backtrace in a global HashMap.
/// This function records the creation of a garbage-collected object.
/// It takes a raw pointer to the object and stores it along with a
/// backtrace in a global HashMap.
#[no_mangle]
pub unsafe extern "C" fn record_gc_object_creation(gc_object_link: *mut ListHead) {
// Convert the pointer to the 'link' field back to a pointer to the encompassing struct
Expand Down
2 changes: 1 addition & 1 deletion src/libbf.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#endif

#include "mimalloc.h"
#include "core/convertion.h"
#include "core/conversion.h"
#include "quickjs/cutils.h"
#include "quickjs/libbf.h"

Expand Down
8 changes: 4 additions & 4 deletions tests/test-ecma-262.conf → tests/test262.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ module=yes
verbose=yes

# load harness files from this directory
harnessdir=test262/harness
harnessdir=../test262/harness

# names of harness include files to skip
#harnessexclude=

# name of the error file for known errors
errorfile=test262_errors.txt
errorfile=../test262_errors.txt

# exclude tests enumerated in this file (see also [exclude] section)
#excludefile=test262_exclude.txt

# report test results to this file
reportfile=test262_report.txt
reportfile=../test262_report.txt

# enumerate tests from this directory
testdir=test262/test
testdir=../test262/test

[features]
# Standard language features and proposed extensions
Expand Down

0 comments on commit 5ce355e

Please sign in to comment.