コミットメタ情報

リビジョンb1c00a16f770a44b9b011f94cf897a16adef6aaa (tree)
日時2018-03-12 13:41:53
作者Agustina Arzille <avarzille@rise...>
コミッターAgustina Arzille

ログメッセージ

Improvements in stream interface and GC

変更サマリ

差分

diff -r aa77bec1d5b3 -r b1c00a16f770 compiler.cpp
--- a/compiler.cpp Fri Mar 09 17:08:24 2018 -0300
+++ b/compiler.cpp Mon Mar 12 04:41:53 2018 +0000
@@ -2462,7 +2462,7 @@
24622462 if ((n = *ip++) > 0)
24632463 {
24642464 list_fct (interp, &stack[sp - n], n);
2465- interp->popn (n);
2465+ sp -= n;
24662466 U_PUSH (retval);
24672467 }
24682468 else
@@ -2678,6 +2678,7 @@
26782678 sx = fetch32 (ip);
26792679 nargs = process_keys (interp, retval, ix,
26802680 n, abs (sx) - ix - n, bp, nargs, sx < 0);
2681+ lastf = interp->cur_frame;
26812682 NEXT_OP;
26822683
26832684 OP_(MKCONT):
diff -r aa77bec1d5b3 -r b1c00a16f770 io.cpp
--- a/io.cpp Fri Mar 09 17:08:24 2018 -0300
+++ b/io.cpp Mon Mar 12 04:41:53 2018 +0000
@@ -1559,7 +1559,9 @@
15591559 if (!ptr)
15601560 qp_return (str);
15611561
1562- stream *ns = strstream (interp, alloc_str (interp, 0), STRM_WRITE);
1562+ stream *ns = strstream (interp,
1563+ alloc_str (interp, 0), STRM_WRITE | STRM_NOLOCK);
1564+
15631565 ns->write (interp, start, ptr - start);
15641566
15651567 valref outs (interp, ns->as_obj ()), args (interp, NIL);
@@ -1649,8 +1651,8 @@
16491651 bool init_io (interpreter *interp)
16501652 {
16511653 static native_function backquote_macro;
1652- auto nfp = (native_function *)ensure_mask (&backquote_macro, TYPE_SHIFT);
1653- native_function::add_macro (interp, "backquote", backquote_fct, nfp);
1654+ native_function::add_macro (interp, "backquote", backquote_fct,
1655+ (native_function *)ensure_mask (&backquote_macro, TYPE_SHIFT));
16541656
16551657 return (true);
16561658 }
diff -r aa77bec1d5b3 -r b1c00a16f770 memory.cpp
--- a/memory.cpp Fri Mar 09 17:08:24 2018 -0300
+++ b/memory.cpp Mon Mar 12 04:41:53 2018 +0000
@@ -358,7 +358,7 @@
358358 this->sweep_young_varobjs ();
359359 }
360360
361- void suspend_all (interpreter *interp);
361+ void suspend_one (interpreter *interp, interpreter *target);
362362 void resume_all (interpreter *interp);
363363 };
364364
@@ -682,33 +682,28 @@
682682 # define RESUME_THR(id) ResumeThread (id)
683683 #endif
684684
685-void gcinfo::suspend_all (interpreter *interp)
685+void gcinfo::suspend_one (interpreter *interp, interpreter *target)
686686 {
687- this->event.reset ();
688-
689- for (dlist::iterator it (&all_threads); it.valid (); it.adv ())
690- {
691- interpreter *target = ((thread *)it.getp ())->interp;
692- if (target == interp)
693- continue;
687+ if (target == interp)
688+ return;
694689
695- /* Save the state, and if the thread is not blocking,
696- * suspend it asynchronously. Otherwise, the thread will
697- * have to wait on the GC event once it's done blocking. */
698- target->lock_remote (interp);
699- target->saved_state = target->state;
700- target->state = INTERP_SUSPENDED;
701- target->sync_ev() = &this->event;
690+ /* Save the state, and if the thread is not blocking,
691+ * suspend it asynchronously. Otherwise, the thread will
692+ * have to wait on the GC event once it's done blocking. */
702693
703- if (target->saved_state == INTERP_RUNNING)
704- {
705- suspend_thr (as_thread(target->thread)->osid);
706- // Wait for thread to acknowledge signal.
707- this->event.post_send ();
708- }
694+ target->lock_remote (interp);
695+ target->saved_state = target->state;
696+ target->state = INTERP_SUSPENDED;
697+ target->sync_ev() = &this->event;
709698
710- target->unlock ();
699+ if (target->saved_state == INTERP_RUNNING)
700+ {
701+ suspend_thr (as_thread(target->thread)->osid);
702+ // Wait for thread to acknowledge signal.
703+ this->event.post_send ();
711704 }
705+
706+ target->unlock ();
712707 }
713708
714709 void gcinfo::resume_all (interpreter *interp)
@@ -954,26 +949,25 @@
954949 sigaction (SIG_SUSPEND, &sa, &old);
955950 #endif
956951
957- this->suspend_all (interp);
958-
959- // The world is stopped. Time for the mark phase.
960- atomic_mfence_acq (); // Synchronize with every other thread.
952+ this->event.reset ();
961953
962954 for (dlist::iterator it (&all_threads); it.valid (); it.adv ())
963955 {
964956 thread *thrp = (thread *)it.getp ();
965957 interpreter *ip2 = thrp->interp;
966958
959+ this->suspend_one (interp, ip2);
960+
967961 // Mark the interpreter's registers.
968- gc_mark (ip2->thread, mask);
969- gc_mark (ip2->lasterr, mask);
970- gc_mark (ip2->retval, mask);
971- gc_mark (ip2->alval, mask);
972- gc_mark (ip2->aux, mask);
962+ this->mark (ip2->thread, mask);
963+ this->mark (ip2->lasterr, mask);
964+ this->mark (ip2->retval, mask);
965+ this->mark (ip2->alval, mask);
966+ this->mark (ip2->aux, mask);
973967
974968 // Mark the interpreter's stack.
975969 for (uint32_t i = 0; i < ip2->sp; ++i)
976- gc_mark (ip2->stack[i], mask);
970+ this->mark (ip2->stack[i], mask);
977971
978972 // Mark the thread's locks.
979973 for (dlist::iterator lk (&thrp->locks); lk.valid (); lk.adv ())
@@ -981,7 +975,7 @@
981975
982976 for (valref_base *vp = ip2->values.next;
983977 vp != &ip2->values; vp = vp->next)
984- gc_mark (vp->value, mask);
978+ this->mark (vp->value, mask);
985979
986980 if (full)
987981 ip2->mmgr->clear_bitmaps (this->conses_per_page);
diff -r aa77bec1d5b3 -r b1c00a16f770 signals.cpp
--- a/signals.cpp Fri Mar 09 17:08:24 2018 -0300
+++ b/signals.cpp Mon Mar 12 04:41:53 2018 +0000
@@ -30,7 +30,7 @@
3030 sigint_fct.flags = native_function::native_flag;
3131 sigint_fct.type = typecode::FCT;
3232 sigint_fct.fct = sigint_handler;
33- sigint_fct.name = "sigint_handler";
33+ sigint_fct.name = "sigint-handler";
3434 signal_handlers[SIGINT - 1] = sigint_fct.as_obj ();
3535
3636 struct sigaction sa;
diff -r aa77bec1d5b3 -r b1c00a16f770 stream.cpp
--- a/stream.cpp Fri Mar 09 17:08:24 2018 -0300
+++ b/stream.cpp Mon Mar 12 04:41:53 2018 +0000
@@ -18,6 +18,12 @@
1818 return (false);
1919 }
2020
21+static void
22+fini_stream (void *self)
23+{
24+ ((stream *)self)->close (interpreter::self ());
25+}
26+
2127 spos spos::decode (object obj)
2228 {
2329 spos ret (0);
@@ -68,24 +74,20 @@
6874 char *wrbuf = ret->rdbuf.start + ((mode & STRM_BID) ? bufsiz : 0);
6975 ret->wrbuf.init (wrbuf, bufsiz);
7076
71- interp->push (ret->bvec);
72- ret->ilock = alloc_lock (interp, true);
77+ valref bv (interp, ret->bvec);
78+ ret->ilock = (mode & STRM_NOLOCK) ? UNBOUND : alloc_lock (interp, true);
7379 ret->flags = mode;
7480
75- if (ret->flags & STRM_APP)
81+ if (!(ret->flags & STRM_APP))
82+ ret->pos = intobj (0);
83+ else if (!ret->xseek (interp, spos (0), SEEK_END))
7684 {
77- valref ref (interp, ret->bvec);
78- if (!ret->xseek (interp, spos (0), SEEK_END))
79- {
80- xfree (ret);
81- ret = nullptr;
82- }
85+ xfree (ret);
86+ return (nullptr);
8387 }
84- else
85- ret->pos = intobj (0);
8688
89+ ret->fini = fini_stream;
8790 interp->alval = ret->as_obj ();
88- interp->popn ();
8991 gcregister (interp, ret);
9092 return (ret);
9193 }
diff -r aa77bec1d5b3 -r b1c00a16f770 stream.h
--- a/stream.h Fri Mar 09 17:08:24 2018 -0300
+++ b/stream.h Mon Mar 12 04:41:53 2018 +0000
@@ -31,7 +31,7 @@
3131 static spos decode (object obj);
3232 };
3333
34-/* Stream flags. */
34+// Stream flags.
3535 enum
3636 {
3737 STRM_BUILTIN = 1 << 0,
@@ -48,10 +48,11 @@
4848 STRM_UTF8 = 1 << 10,
4949 STRM_OFFSET = 1 << 11,
5050 STRM_CLOSED = 1 << 12,
51- STRM_BID = 1 << 13
51+ STRM_BID = 1 << 13,
52+ STRM_NOLOCK = 1 << 14
5253 };
5354
54-class stream : public varobj
55+class stream : public finobj
5556 {
5657 public:
5758 class buffer
旧リポジトリブラウザで表示