History

memory system upgrade (part 1); scope-sensitive cleanup for each return statement; clarified reference counting semantics; function argument release for builtin functions; improved post-function call object cleanup; auto-reference-increment on returned objects from all builtin/imported functions; absyn tree printing for instruction dumping abysn2str(); Machine.refcount() and refcount printing for object references

Ge Wang committed 3 years ago

Commit beef6541 parent 2eec4e717 files · +835 −72Browse files

Showing the changes to src/core/ulib_machine.cpp (1 of 17 files). Show all

Unified · Split

src/core/ulib_machine.cpp+34−2
@@ -40,6 +40,25 @@ · 39 unmodified lines
4040 #include <string>
4141 using namespace std;
4242
43+// exports
44+CK_DLL_SFUN( machine_crash_impl );
45+CK_DLL_SFUN( machine_add_impl );
46+CK_DLL_SFUN( machine_spork_impl );
47+CK_DLL_SFUN( machine_remove_impl );
48+CK_DLL_SFUN( machine_replace_impl );
49+CK_DLL_SFUN( machine_status_impl );
50+CK_DLL_SFUN( machine_intsize_impl );
51+CK_DLL_SFUN( machine_shreds_impl );
52+CK_DLL_SFUN( machine_realtime_impl );
53+CK_DLL_SFUN( machine_silent_impl );
54+CK_DLL_SFUN( machine_eval_impl );
55+CK_DLL_SFUN( machine_eval2_impl );
56+CK_DLL_SFUN( machine_eval3_impl );
57+CK_DLL_SFUN( machine_version_impl );
58+CK_DLL_SFUN( machine_setloglevel_impl );
59+CK_DLL_SFUN( machine_getloglevel_impl );
60+CK_DLL_SFUN( machine_refcount_impl);
61+
4362
4463
4564
@@ -154,7 +173,7 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 108 unmodified lines
154173 QUERY->add_sfun( QUERY, machine_version_impl, "string", "version" );
155174 QUERY->doc_func( QUERY, "return version string" );
156175
157− // get version string
176+ // get set loglevel
158177 QUERY->add_sfun( QUERY, machine_setloglevel_impl, "int", "loglevel" );
159178 QUERY->add_arg( QUERY, "int", "level" );
160179 QUERY->doc_func( QUERY, "set log level\n"
@@ -170,10 +189,15 @@ DLL_QUERY machine_query( Chuck_DL_Query * QUERY ) · 9 unmodified lines
170189 " |- 9: FINEST\n"
171190 " |- 10: ALL" );
172191
173− // get version string
192+ // get log level
174193 QUERY->add_sfun( QUERY, machine_getloglevel_impl, "int", "loglevel" );
175194 QUERY->doc_func( QUERY, "get log level." );
176195
196+ // get reference count for any object
197+ QUERY->add_sfun( QUERY, machine_refcount_impl, "int", "refcount" );
198+ QUERY->add_arg( QUERY, "Object", "obj" );
199+ QUERY->doc_func( QUERY, "get an object's current internal reference count; this is intended for testing or curiosity; NOTE: this function intentionally does not take into account any reference counting related to the calling of this function (normally all functions increments the reference count for objects passed as arguments and decrements upon returning)" );
200+
177201 // end class
178202 QUERY->end_class( QUERY );
179203
@@ -399,3 +423,11 @@ CK_DLL_SFUN( machine_getloglevel_impl ) · 219 unmodified lines
399423 // return
400424 RETURN->v_int = VM->carrier()->chuck->getLogLevel();
401425 }
426+
427+CK_DLL_SFUN( machine_refcount_impl )
428+{
429+ // get the argument
430+ Chuck_Object * obj = (Chuck_Object *)GET_NEXT_OBJECT(ARGS);
431+ // return (-1 to account for the extra refcount as part of calling this function!)
432+ RETURN->v_int = obj != NULL ? obj->m_ref_count-1 : 0;
433+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t