diff --git a/basis/stack-checker/known-words/known-words.factor b/basis/stack-checker/known-words/known-words.factor index 8cddac5a75..d064776673 100644 --- a/basis/stack-checker/known-words/known-words.factor +++ b/basis/stack-checker/known-words/known-words.factor @@ -507,10 +507,10 @@ M: bad-executable summary \ (save-image-and-exit) { byte-array } { } define-primitive -\ data-room { } { integer integer array } define-primitive +\ data-room { } { array } define-primitive \ data-room make-flushable -\ code-room { } { integer integer integer integer } define-primitive +\ code-room { } { array } define-primitive \ code-room make-flushable \ micros { } { integer } define-primitive diff --git a/basis/tools/memory/memory.factor b/basis/tools/memory/memory.factor index 81785f7ea4..2f1827a8ff 100644 --- a/basis/tools/memory/memory.factor +++ b/basis/tools/memory/memory.factor @@ -1,4 +1,4 @@ -! Copyright (C) 2005, 2008 Slava Pestov. +! Copyright (C) 2005, 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences arrays generic assocs io math namespaces parser prettyprint strings io.styles words @@ -8,48 +8,41 @@ IN: tools.memory string dup length 4 > [ 3 cut* "," glue ] when - " KB" append write-cell ; + " KB" append ; -: write-total/used/free ( free total str -- ) - [ - write-cell - dup write-size - over - write-size - write-size - ] with-row ; +: memory-table. ( sizes seq -- ) + swap [ kilobytes ] map zip simple-table. ; -: write-total ( n str -- ) - [ - write-cell - write-size - [ ] with-cell - [ ] with-cell - ] with-row ; +: young-room. ( seq -- ) + { "Total:" "Allocated:" "Free:" } memory-table. ; -: write-headings ( seq -- ) - [ [ write-cell ] each ] with-row ; +: nursery-room. ( seq -- ) "- Nursery space" print young-room. ; -: (data-room.) ( -- ) - data-room 2 [ - [ first2 ] [ number>string "Generation " prepend ] bi* - write-total/used/free - ] each-index - "Decks" write-total - "Cards" write-total ; +: aging-room. ( seq -- ) "- Aging space" print young-room. ; -: write-labeled-size ( n string -- ) - [ write-cell write-size ] with-row ; +: mark-sweep-table. ( sizes -- ) + { "Total:" "Allocated:" "Contiguous free:" "Total free:" } memory-table. ; -: (code-room.) ( -- ) - code-room { - [ "Size:" write-labeled-size ] - [ "Used:" write-labeled-size ] - [ "Total free space:" write-labeled-size ] - [ "Largest free block:" write-labeled-size ] - } spread ; +: tenured-room. ( seq -- ) "- Tenured space" print mark-sweep-table. ; + +: misc-room. ( seq -- ) + "- Miscellaneous buffers" print + { "Card array:" "Deck array:" "Mark stack:" } memory-table. ; + +: data-room. ( -- ) + "==== DATA HEAP" print nl + data-room + 3 cut [ nursery-room. nl ] dip + 3 cut [ aging-room. nl ] dip + 4 cut [ tenured-room. nl ] dip + misc-room. ; + +: code-room. ( -- ) + "==== CODE HEAP" print nl + code-room mark-sweep-table. ; : heap-stat-step ( obj counts sizes -- ) [ [ class ] dip inc-at ] @@ -57,18 +50,7 @@ IN: tools.memory PRIVATE> -: room. ( -- ) - "==== DATA HEAP" print - standard-table-style [ - { "" "Total" "Used" "Free" } write-headings - (data-room.) - ] tabular-output - nl nl - "==== CODE HEAP" print - standard-table-style [ - (code-room.) - ] tabular-output - nl ; +: room. ( -- ) data-room. nl code-room. ; : heap-stats ( -- counts sizes ) [ ] instances H{ } clone H{ } clone @@ -76,7 +58,7 @@ PRIVATE> : heap-stats. ( -- ) heap-stats dup keys natural-sort standard-table-style [ - { "Class" "Bytes" "Instances" } write-headings + [ { "Class" "Bytes" "Instances" } [ write-cell ] each ] with-row [ [ dup pprint-cell diff --git a/vm/code_heap.cpp b/vm/code_heap.cpp index 2ce6d00b7c..ae53869ef2 100755 --- a/vm/code_heap.cpp +++ b/vm/code_heap.cpp @@ -197,12 +197,18 @@ void factor_vm::primitive_modify_code_heap() /* Push the free space and total size of the code heap */ void factor_vm::primitive_code_room() { + growable_array a(this); + cell used, total_free, max_free; code->allocator->usage(&used,&total_free,&max_free); - dpush(tag_fixnum(code->seg->size / 1024)); - dpush(tag_fixnum(used / 1024)); - dpush(tag_fixnum(total_free / 1024)); - dpush(tag_fixnum(max_free / 1024)); + + a.add(tag_fixnum(code->seg->size >> 10)); + a.add(tag_fixnum(used >> 10)); + a.add(tag_fixnum(total_free >> 10)); + a.add(tag_fixnum(max_free >> 10)); + + a.trim(); + dpush(a.elements.value()); } struct stack_trace_stripper { diff --git a/vm/data_heap.cpp b/vm/data_heap.cpp index 57f6608e6b..3dd46fd848 100755 --- a/vm/data_heap.cpp +++ b/vm/data_heap.cpp @@ -204,22 +204,26 @@ void factor_vm::primitive_size() /* Push memory usage statistics in data heap */ void factor_vm::primitive_data_room() { - dpush(tag_fixnum((data->cards_end - data->cards) >> 10)); - dpush(tag_fixnum((data->decks_end - data->decks) >> 10)); - growable_array a(this); - a.add(tag_fixnum((nursery.end - nursery.here) >> 10)); a.add(tag_fixnum((nursery.size) >> 10)); + a.add(tag_fixnum((nursery.here - nursery.start) >> 10)); + a.add(tag_fixnum((nursery.end - nursery.here) >> 10)); - a.add(tag_fixnum((data->aging->end - data->aging->here) >> 10)); a.add(tag_fixnum((data->aging->size) >> 10)); + a.add(tag_fixnum((data->aging->here - data->aging->start) >> 10)); + a.add(tag_fixnum((data->aging->end - data->aging->here) >> 10)); - //XXX cell used, total_free, max_free; data->tenured->usage(&used,&total_free,&max_free); - a.add(tag_fixnum(total_free >> 10)); a.add(tag_fixnum(data->tenured->size >> 10)); + a.add(tag_fixnum(used >> 10)); + a.add(tag_fixnum(total_free >> 10)); + a.add(tag_fixnum(max_free >> 10)); + + a.add(tag_fixnum((data->cards_end - data->cards) >> 10)); + a.add(tag_fixnum((data->decks_end - data->decks) >> 10)); + a.add(tag_fixnum((data->tenured->mark_stack.capacity()) >> 10)); a.trim(); dpush(a.elements.value());