00001
00002 #include <sys/types.h>
00003 #include <stdio.h>
00004 #include <errno.h>
00005 #include <stdlib.h>
00006 #include <string.h>
00007 #include <assert.h>
00008 #include <math.h>
00009
00010
00011 #define __STDC_FORMAT_MACROS 1
00012
00013
00014 #define __STDC_LIMIT_MACROS 1
00015
00016 #ifdef WIN32
00017
00018 #include "stdint.h"
00019 #include "inttypes.h"
00020 #else
00021 #include <stdint.h>
00022 #include <inttypes.h>
00023 #endif
00024 #include <fcntl.h>
00025 #include <time.h>
00026 #include <limits.h>
00027 #ifdef WIN32
00028 #include <winsock2.h>
00029 #include <ws2tcpip.h>
00030 #include <windows.h>
00031
00032 typedef signed int ssize_t;
00033 typedef SOCKADDR sockaddr_un;
00034 #else
00035 #include <sys/socket.h>
00036 #include <sys/wait.h>
00037 #include <sys/select.h>
00038 #include <netinet/in.h>
00039 #include <netdb.h>
00040 #include <unistd.h>
00041 #include <sys/time.h>
00042 #include <sys/un.h>
00043 #include <pthread.h>
00044 #include <sys/stat.h>
00045 #endif
00046
00047 #include <dirent.h>
00048
00049
00050
00051 #include <set>
00052 #include <stack>
00053 #include <vector>
00054 #include <map>
00055 #include <algorithm>
00056
00057
00058 #ifndef SLATE_BUILD_TYPE
00059 #define SLATE_BUILD_TYPE "UNDEFINED"
00060 #endif
00061
00062 typedef uintptr_t uword_t;
00063 typedef intptr_t word_t;
00064 typedef uint8_t byte_t;
00065 typedef word_t bool_t;
00066 typedef float float_type;
00067
00068 #define WORDT_MAX INTPTR_MAX
00069
00070 #define KB 1024
00071 #define MB 1024 * 1024
00072 #define GB 1024 * 1024 * 1024
00073
00074 #define ASSERT(x) assert(x)
00075 #define str(s) #s
00076 #define xstr(s) str(s)
00077 #define MAX(a, b) (a > b ? a : b)
00078 #define MIN(a, b) (a < b ? a : b)
00079
00080 struct SlotTable;
00081 struct Symbol;
00082 struct CompiledMethod;
00083 struct LexicalContext;
00084 struct RoleTable;
00085 struct OopArray;
00086 struct MethodDefinition;
00087 struct Object;
00088 struct ByteArray;
00089 struct MethodCacheEntry;
00090 struct Closure;
00091 struct Interpreter;
00092 struct ForwardedObject;
00093 struct Map;
00094 struct BreakEntry;
00095 struct PrimitiveMethod;
00096 struct RoleEntry;
00097 struct SlotEntry;
00098
00099 struct slate_image_header {
00100 word_t magic;
00101 word_t size;
00102 word_t next_hash;
00103 word_t special_objects_oop;
00104 word_t current_dispatch_id;
00105 };
00106 struct Object
00107 {
00108 word_t header;
00109 word_t objectSize;
00110 word_t payloadSize;
00111
00112 struct Map * map;
00113
00114 };
00115
00116
00117
00118 #define HEADER_SIZE (sizeof(struct Object) - sizeof(struct Map*))
00119 #define HEADER_SIZE_WORDS (HEADER_SIZE/sizeof(word_t))
00120 #define SLATE_IMAGE_MAGIC (word_t)0xABCDEF43
00121
00122 #ifdef _MSC_VER
00123 #define SLATE_INLINE
00124 #pragma warning(disable : 4996)
00125 #else
00126 #define SLATE_INLINE inline
00127
00128
00129 #endif
00130
00131 #define METHOD_CACHE_ARITY 6
00132
00133 struct MethodCacheEntry
00134 {
00135 struct MethodDefinition * method;
00136 struct Symbol* selector;
00137 struct Map * maps[METHOD_CACHE_ARITY];
00138 };
00139 struct ForwardedObject
00140 {
00141 word_t header;
00142 word_t objectSize;
00143 word_t payloadSize;
00144 struct Object * target;
00145 };
00146 struct ForwardPointerEntry
00147 {
00148 struct Object* fromObj;
00149 struct Object* toObj;
00150 };
00151 struct Map
00152 {
00153 struct Object base;
00154 struct Object* flags;
00155 struct Object* representative;
00156 struct OopArray * delegates;
00157 struct Object* slotCount;
00158 struct SlotTable * slotTable;
00159 struct RoleTable * roleTable;
00160 word_t dispatchID;
00161 word_t visitedPositions;
00162 };
00163 struct BreakEntry
00164 {
00165 word_t oldAddress;
00166 word_t newAddress;
00167 };
00168 struct PrimitiveMethod
00169 {
00170 struct Object base;
00171 struct Object* index;
00172 struct Object* selector;
00173 struct Object* inputVariables;
00174 };
00175 struct RoleEntry
00176 {
00177 struct Symbol* name;
00178 struct Object* rolePositions;
00179 struct MethodDefinition * methodDefinition;
00180 struct Object* nextRole;
00181 };
00182 struct SlotEntry
00183 {
00184 struct Symbol* name;
00185 struct Object* offset;
00186 };
00187 struct SlotTable
00188 {
00189 struct Object base;
00190 struct SlotEntry slots[];
00191 };
00192 struct Symbol
00193 {
00194 struct Object base;
00195 struct Object* cacheMask;
00196 byte_t elements[];
00197 };
00198 struct CompiledMethod
00199 {
00200 struct Object base;
00201 struct CompiledMethod * method;
00202 struct Symbol* selector;
00203 struct Object* inputVariables;
00204 struct Object* localVariables;
00205 struct Object* restVariable;
00206 struct OopArray * optionalKeywords;
00207 struct Object* heapAllocate;
00208 struct Object* environment;
00209 struct OopArray * literals;
00210 struct OopArray * selectors;
00211 struct OopArray * code;
00212 word_t sourceTree;
00213 word_t debugMap;
00214 struct Object* isInlined;
00215 struct OopArray* oldCode;
00216 struct Object* callCount;
00217
00218 struct OopArray* calleeCount;
00219 struct Object* registerCount;
00220 struct OopArray* cachedInCallers;
00221 struct Object* cachedInCallersCount;
00222 struct Object* nextInlineAtCallCount;
00223 struct Object* reserved5;
00224 struct Object* reserved6;
00225 };
00226 struct LexicalContext
00227 {
00228 struct Object base;
00229 struct Object* framePointer;
00230 struct Object* variables[];
00231 };
00232 struct RoleTable
00233 {
00234 struct Object base;
00235 struct RoleEntry roles[];
00236 };
00237 struct OopArray
00238 {
00239 struct Object base;
00240 struct Object* elements[];
00241 };
00242 struct MethodDefinition
00243 {
00244 struct Object base;
00245 struct Object* method;
00246 struct Object* slotAccessor;
00247 word_t dispatchID;
00248 word_t dispatchPositions;
00249 word_t foundPositions;
00250 word_t dispatchRank;
00251 };
00252
00253 struct ByteArray
00254 {
00255 struct Object base;
00256 byte_t elements[];
00257 };
00258 struct Closure
00259 {
00260 struct Object base;
00261 struct CompiledMethod * method;
00262 struct LexicalContext * lexicalWindow[];
00263 };
00264 struct Interpreter
00265 {
00266 struct Object base;
00267 struct OopArray * stack;
00268 struct CompiledMethod * method;
00269 struct Closure * closure;
00270 struct LexicalContext * lexicalContext;
00271 struct Object* ensureHandlers;
00272
00273 word_t framePointer;
00274 word_t codePointer;
00275 word_t codeSize;
00276 word_t stackPointer;
00277 word_t stackSize;
00278 };
00279
00280 #define SLATE_ERROR_RETURN (-1)
00281 #define SLATE_FILE_NAME_LENGTH 512
00282 #define DELEGATION_STACK_SIZE 256
00283 #define PROFILER_ENTRY_COUNT 4096
00284 #define MARK_MASK 1
00285 #define METHOD_CACHE_SIZE 1024*64
00286 #define OLD_TO_NEW_CARD_SIZE (sizeof(word_t) * 8)
00287 #define SLATE_MEMS_MAXIMUM 1024
00288 #define SLATE_NETTICKET_MAXIMUM 1024
00289 #define SLATE_FILES_MAXIMUM 256
00290 #define SLATE_DIRECTORIES_MAXIMUM 256
00291 #define MAX_PLATFORM_STRING_LENGTH 256
00292
00293 #ifndef WIN32
00294 #include <sys/utsname.h>
00295 #else
00296 typedef struct utsname {
00297 char sysname[MAX_PLATFORM_STRING_LENGTH];
00298 char nodename[MAX_PLATFORM_STRING_LENGTH];
00299 char release[MAX_PLATFORM_STRING_LENGTH];
00300 char version[MAX_PLATFORM_STRING_LENGTH];
00301 char machine[MAX_PLATFORM_STRING_LENGTH];
00302 };
00303 int uname(struct utsname *un);
00304 #endif
00305
00306 #ifdef WIN32
00307 int getpid();
00308 #endif
00309
00310 template <class T> class Pinned;
00311
00312
00313
00314 struct object_heap;
00315
00316 struct slate_addrinfo_request {
00317
00318
00319 char* hostname;
00320 char* service;
00321
00322 word_t family, type, protocol, flags;
00323
00324
00325 struct object_heap* oh;
00326 word_t result, ticketNumber;
00327 word_t inUse;
00328 word_t finished;
00329 struct addrinfo* addrResult;
00330 };
00331
00332
00333
00334 struct object_heap
00335 {
00336 byte_t mark_color;
00337 byte_t * memoryOld;
00338 byte_t * memoryYoung;
00339 word_t memoryOldSize;
00340 word_t memoryYoungSize;
00341 word_t memoryOldLimit;
00342 word_t memoryYoungLimit;
00343 struct OopArray* special_objects_oop;
00344 word_t current_dispatch_id;
00345 bool_t interrupt_flag;
00346 bool_t quiet;
00347 bool_t quietGC;
00348 bool_t automaticallyInline;
00349 word_t lastHash;
00350 word_t method_cache_hit, method_cache_access;
00351 word_t gcTenureCount;
00352
00353 char** envp;
00354
00355
00356 FILE** file_index;
00357 word_t file_index_size;
00358
00359
00360 DIR** dir_index;
00361 word_t dir_index_size;
00362
00363 struct Object *nextFree;
00364 struct Object *nextOldFree;
00365 struct Object* delegation_stack[DELEGATION_STACK_SIZE];
00366 struct MethodCacheEntry methodCache[METHOD_CACHE_SIZE];
00367
00368
00369 std::multiset<struct CompiledMethod*> optimizedMethods;
00370
00371
00372
00373
00374 std::vector<struct Object*> tenuredObjects;
00375
00376
00377 void* memory_areas [SLATE_MEMS_MAXIMUM];
00378 int memory_sizes [SLATE_MEMS_MAXIMUM];
00379 int memory_num_refs [SLATE_MEMS_MAXIMUM];
00380
00381 struct slate_addrinfo_request* socketTickets;
00382 int socketTicketCount;
00383 #ifdef WIN32
00384 HANDLE WINAPI socketThreadMutex;
00385 #if 0
00386 pthread_mutex_t socketTicketMutex;
00387 #endif
00388 #endif
00389
00390 int argcSaved;
00391 char** argvSaved;
00392
00393 struct utsname platform_info;
00394
00395 struct Object** markStack;
00396 size_t markStackSize;
00397 size_t markStackPosition;
00398
00399 std::set<struct Object*> rememberedOldObjects;
00400
00401 void* stackBottom;
00402
00403 bool_t currentlyProfiling;
00404 int64_t profilerTimeStart, profilerTime, profilerLastTime;
00405 std::set<struct Object*> profiledMethods;
00406 std::map<struct Object*,word_t> profilerCallCounts;
00407 std::map<struct Object*,word_t> profilerSelfTime;
00408 std::map<struct Object*, std::map<struct Object*,word_t> > profilerChildCallCount;
00409 std::map<struct Object*, std::map<struct Object*,word_t> > profilerChildCallTime;
00410 std::vector<struct Object*> profilerCallStack;
00411 std::vector<word_t> profilerCallStackTimes;
00412
00413
00414
00415 word_t doFullGCNext;
00416
00417
00418
00419
00420
00421
00422
00423
00424 struct {
00425 struct Interpreter* interpreter;
00426 struct Object* true_object;
00427 struct Object* false_object;
00428 struct Object* nil;
00429 struct Object* primitive_method_window;
00430 struct Object* compiled_method_window;
00431 struct Object* closure_method_window;
00432 } cached;
00433 };
00434
00435
00436
00437
00438 #define SMALLINT_MASK 0x1
00439 #define PINNED_MASK 0x3F
00440 #define PINNED_OFFSET 24
00441 #define ID_HASH_RESERVED 0x7FFFF0
00442 #define ID_HASH_FORWARDED ID_HASH_RESERVED
00443 #define ID_HASH_FREE 0x7FFFFF
00444 #define ID_HASH_MAX ID_HASH_FREE
00445
00446
00447 #define FLOAT_SIGNIFICAND 0x7FFFFF
00448 #define FLOAT_EXPONENT_OFFSET 23
00449
00450
00451
00452
00453 #define MAP_FLAG_RESTRICT_DELEGATION 2
00454 #define MAP_FLAG_IMMUTABLE 4
00455
00456
00457 #define WORD_BYTES_MINUS_ONE (sizeof(word_t)-1)
00458 #define ROLE_ENTRY_WORD_SIZE ((sizeof(struct RoleEntry) + WORD_BYTES_MINUS_ONE) / sizeof(word_t))
00459 #define SLOT_ENTRY_WORD_SIZE ((sizeof(struct SlotEntry) + WORD_BYTES_MINUS_ONE) / sizeof(word_t))
00460 #define FUNCTION_FRAME_SIZE 6
00461
00462 #define FRAME_OFFSET_BEFORE_CALL_STACK_POINTER 6
00463 #define FRAME_OFFSET_RESULT_STACK_POINTER 5
00464 #define FRAME_OFFSET_CODE_POINTER 4
00465 #define FRAME_OFFSET_METHOD 3
00466 #define FRAME_OFFSET_LEXICAL_CONTEXT 2
00467 #define FRAME_OFFSET_PREVIOUS_FRAME_POINTER 1
00468 #define FRAME_OFFSET_FIRST_REGISTER 0
00469
00470
00471 #define TRUE 1
00472 #define FALSE 0
00473
00474 #define TYPE_OBJECT 0
00475 #define TYPE_OOP_ARRAY 1
00476 #define TYPE_BYTE_ARRAY 2
00477
00478 #define INLINER_MAX_INLINE_SIZE 50
00479 #define INLINER_MAX_METHOD_SIZE 200
00480
00481 #define CALLER_PIC_SETUP_AFTER 500
00482 #define CALLER_PIC_MAX_CODE_SIZE 70
00483 #define CALLEE_OPTIMIZE_AFTER 1000
00484 #define CALLER_PIC_SIZE 16
00485 #define CALLER_PIC_ENTRY_SIZE 4
00486 #define PIC_CALLEE 0
00487 #define PIC_CALLEE_ARITY 1
00488 #define PIC_CALLEE_MAPS 2
00489 #define PIC_CALLEE_COUNT 3
00490
00491 #define SPECIAL_OOP_LOBBY 0
00492 #define SPECIAL_OOP_NO_ROLE 1
00493 #define SPECIAL_OOP_NIL 2
00494 #define SPECIAL_OOP_TRUE 3
00495 #define SPECIAL_OOP_FALSE 4
00496 #define SPECIAL_OOP_ARRAY_PROTO 5
00497 #define SPECIAL_OOP_BYTE_ARRAY_PROTO 6
00498 #define SPECIAL_OOP_ASCII_PROTO 7
00499 #define SPECIAL_OOP_MAP_PROTO 8
00500 #define SPECIAL_OOP_METHOD_DEF_PROTO 9
00501 #define SPECIAL_OOP_SMALL_INT_PROTO 10
00502 #define SPECIAL_OOP_FLOAT_PROTO 11
00503 #define SPECIAL_OOP_CLOSURE_WINDOW 12
00504 #define SPECIAL_OOP_COMPILED_METHOD_WINDOW 13
00505 #define SPECIAL_OOP_PRIMITIVE_METHOD_WINDOW 14
00506 #define SPECIAL_OOP_CLOSURE_PROTO 15
00507 #define SPECIAL_OOP_LEXICAL_CONTEXT_PROTO 16
00508 #define SPECIAL_OOP_INTERPRETER 17
00509 #define SPECIAL_OOP_ENSURE_MARKER 18
00510 #define SPECIAL_OOP_NOT_FOUND_ON 19
00511 #define SPECIAL_OOP_NOT_FOUND_ON_AFTER 20
00512 #define SPECIAL_OOP_WRONG_INPUTS_TO 21
00513 #define SPECIAL_OOP_MAY_NOT_RETURN_TO 22
00514 #define SPECIAL_OOP_SLOT_NOT_FOUND_NAMED 23
00515 #define SPECIAL_OOP_KEY_NOT_FOUND_ON 24
00516 #define SPECIAL_OOP_IMMUTABLE 25
00517 #define SPECIAL_OOP_BIT_SHIFT_OVERFLOW 26
00518 #define SPECIAL_OOP_ADD_OVERFLOW 27
00519 #define SPECIAL_OOP_SUBTRACT_OVERFLOW 28
00520 #define SPECIAL_OOP_MULTIPLY_OVERFLOW 29
00521 #define SPECIAL_OOP_DIVIDE_BY_ZERO 30
00522 #define SPECIAL_OOP_NOT_A_BOOLEAN 31
00523 #define SPECIAL_OOP_APPLY_TO 32
00524 #define SPECIAL_OOP_OPTIONALS 33
00525 #define SPECIAL_OOP_TYPE_ERROR_ON 34
00526 #define SPECIAL_OOP_COUNT 35
00527
00528 #define SF_READ 1
00529 #define SF_WRITE 1 << 1
00530 #define SF_CREATE 1 << 2
00531 #define SF_CLEAR 1 << 3
00532
00533
00534 #define SLATE_DOMAIN_LOCAL 1
00535 #define SLATE_DOMAIN_IPV4 2
00536 #define SLATE_DOMAIN_IPV6 3
00537
00538 #define SLATE_TYPE_STREAM 1
00539
00540 #define SLATE_PROTOCOL_DEFAULT 0
00541
00542
00543
00544 #ifdef PRINT_DEBUG_OPCODES
00545 #define PRINTOP(X) printf(X)
00546 #else
00547 #define PRINTOP(X)
00548 #endif
00549
00550 byte_t* inc_ptr(struct Object* obj, word_t amt);
00551
00552
00553 #define OP_SEND ((0 << 1) | SMALLINT_MASK)
00554
00555
00556 #define OP_LOAD_LITERAL ((3 << 1) | SMALLINT_MASK)
00557
00558 #define OP_SEND_MESSAGE_WITH_OPTS ((5 << 1) | SMALLINT_MASK)
00559
00560 #define OP_NEW_CLOSURE ((7 << 1) | SMALLINT_MASK)
00561 #define OP_NEW_ARRAY_WITH ((8 << 1) | SMALLINT_MASK)
00562 #define OP_RESEND_MESSAGE ((9 << 1) | SMALLINT_MASK)
00563 #define OP_RETURN_FROM ((10 << 1) | SMALLINT_MASK)
00564 #define OP_LOAD_ENVIRONMENT ((11 << 1) | SMALLINT_MASK)
00565 #define OP_LOAD_VARIABLE ((12 << 1) | SMALLINT_MASK)
00566 #define OP_STORE_VARIABLE ((13 << 1) | SMALLINT_MASK)
00567 #define OP_LOAD_FREE_VARIABLE ((14 << 1) | SMALLINT_MASK)
00568 #define OP_STORE_FREE_VARIABLE ((15 << 1) | SMALLINT_MASK)
00569 #define OP_IS_IDENTICAL_TO ((16 << 1) | SMALLINT_MASK)
00570 #define OP_BRANCH_KEYED ((17 << 1) | SMALLINT_MASK)
00571 #define OP_JUMP_TO ((18 << 1) | SMALLINT_MASK)
00572 #define OP_MOVE_REGISTER ((19 << 1) | SMALLINT_MASK)
00573 #define OP_BRANCH_IF_TRUE ((20 << 1) | SMALLINT_MASK)
00574 #define OP_BRANCH_IF_FALSE ((21 << 1) | SMALLINT_MASK)
00575 #define OP_RETURN_REGISTER ((22 << 1) | SMALLINT_MASK)
00576 #define OP_RETURN_VALUE ((23 << 1) | SMALLINT_MASK)
00577 #define OP_RESUME ((24 << 1) | SMALLINT_MASK)
00578 #define OP_PRIMITIVE_DO ((25 << 1) | SMALLINT_MASK)
00579 #define OP_APPLY_TO ((26 << 1) | SMALLINT_MASK)
00580 #define OP_IS_NIL ((27 << 1) | SMALLINT_MASK)
00581 #define OP_INLINE_PRIMITIVE_CHECK ((28 << 1) | SMALLINT_MASK)
00582 #define OP_INLINE_METHOD_CHECK ((29 << 1) | SMALLINT_MASK)
00583 #define OP_ ((30 << 1) | SMALLINT_MASK)
00584
00585
00586
00587 #define OP_INTERNAL_SEND ((100 << 1) | SMALLINT_MASK)
00588 #define OP_INTERNAL_ ((101 << 1) | SMALLINT_MASK)
00589
00590 #define OP_SEND_PARAMETER_0 4
00591
00592
00593
00594 #define SSA_REGISTER(X) (i->stack->elements[i->framePointer + (X)])
00595 #define REG_STACK_POINTER(X) (i->framePointer + (X))
00596 #define SSA_NEXT_PARAM_SMALLINT ((word_t)i->method->code->elements[i->codePointer++]>>1)
00597 #define SSA_NEXT_PARAM_OBJECT (i->method->code->elements[i->codePointer++])
00598 #define ASSERT_VALID_REGISTER(X) (assert((X) < (word_t)i->method->registerCount>>1))
00599
00600
00601
00602 #define HEAP_READ_AND_PIN_ARGS(COUNTER, ARITY, ARGSARRAY, PINNEDARGS) for (COUNTER=0; COUNTER < ARITY; COUNTER++) { \
00603 word_t argReg = SSA_NEXT_PARAM_SMALLINT; \
00604 ARGSARRAY[COUNTER] = SSA_REGISTER(argReg); \
00605 PINNEDARGS[COUNTER] = ARGSARRAY[COUNTER]; \
00606 heap_pin_object(oh, PINNEDARGS[COUNTER]); \
00607 }
00608
00609 #define HEAP_UNPIN_ARGS(COUNTER, PINNEDARGS) for (--COUNTER; COUNTER >= 0; COUNTER--) heap_unpin_object(oh, PINNEDARGS[COUNTER])
00610
00611
00612
00613
00614 #define SOCKET_RETURN(x) (smallint_to_object(socket_return((x < 0)? -errno : x)))
00615
00616 extern int globalInterrupt;
00617 extern void (*primitives[]) (struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00618
00619 #define ASSURE_SMALLINT_ARG(XXX) \
00620 if (!object_is_smallint(args[XXX])) { \
00621 interpreter_signal_with(oh, oh->cached.interpreter, get_special(oh, SPECIAL_OOP_TYPE_ERROR_ON), args[XXX], NULL, resultStackPointer); \
00622 return; \
00623 }
00624
00625 #define ASSURE_NOT_SMALLINT_ARG(XXX) \
00626 if (object_is_smallint(args[XXX])) { \
00627 interpreter_signal_with(oh, oh->cached.interpreter, get_special(oh, SPECIAL_OOP_TYPE_ERROR_ON), args[XXX], NULL, resultStackPointer); \
00628 return; \
00629 }
00630
00631 #define ASSURE_TYPE_ARG(XXX, TYPEXXX) \
00632 if (object_type(args[XXX]) != TYPEXXX) { \
00633 interpreter_signal_with(oh, oh->cached.interpreter, get_special(oh, SPECIAL_OOP_TYPE_ERROR_ON), args[XXX], NULL, resultStackPointer); \
00634 return; \
00635 }
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646 void heap_store_into(struct object_heap* oh, struct Object* src, struct Object* dest);
00647
00648
00649 void heap_gc(struct object_heap* oh);
00650 void heap_full_gc(struct object_heap* oh);
00651 void interpreter_apply_to_arity_with_optionals(struct object_heap* oh, struct Interpreter * i, struct Closure * closure,
00652 struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00653
00654
00655
00656
00657
00658
00659
00660 void send_to_through_arity_with_optionals(struct object_heap* oh,
00661 struct Symbol* selector, struct Object* args[],
00662 struct Object* dispatchers[], word_t arity, struct OopArray* opts,
00663 word_t resultStackPointer);
00664
00665
00666
00667 word_t object_to_smallint(struct Object* xxx);
00668 struct Object* smallint_to_object(word_t xxx);
00669 int64_t getTickCount();
00670 SLATE_INLINE volatile int64_t getRealTimeClock();
00671
00672 bool_t oop_is_object(word_t xxx);
00673 bool_t oop_is_smallint(word_t xxx);
00674 bool_t object_is_smallint(struct Object* xxx);
00675 bool_t object_is_special(struct object_heap* oh, struct Object* obj);
00676 word_t object_markbit(struct Object* xxx);
00677 word_t object_hash(struct Object* xxx);
00678 word_t object_size(struct Object* xxx);
00679 word_t payload_size(struct Object* xxx);
00680 word_t object_type(struct Object* xxx);
00681 word_t object_pin_count(struct Object* xxx);
00682 void object_increment_pin_count(struct Object* xxx);
00683 void object_decrement_pin_count(struct Object* xxx);
00684 void object_zero_pin_count(struct Object* xxx);
00685 void heap_zero_pin_counts_from(struct object_heap* oh, byte_t* memory, word_t memorySize);
00686
00687
00688 void copy_bytes_into(byte_t * src, word_t n, byte_t * dst);
00689 void copy_words_into(void * src, word_t n, void * dst);
00690 void fill_words_with(word_t* dst, word_t n, word_t value);
00691 void fill_bytes_with(byte_t* dst, word_t n, byte_t value);
00692
00693 void print_object(struct Object* oop);
00694 void print_symbol(struct Symbol* name);
00695 void print_byte_array(struct Object* o);
00696 void print_object_with_depth(struct object_heap* oh, struct Object* o, word_t depth, word_t max_depth);
00697 void print_detail(struct object_heap* oh, struct Object* o);
00698 bool_t print_printname(struct object_heap* oh, struct Object* o);
00699 void print_type(struct object_heap* oh, struct Object* o);
00700 void print_stack(struct object_heap* oh);
00701 void print_stack_types(struct object_heap* oh, word_t last_count);
00702 void print_backtrace(struct object_heap* oh);
00703 void heap_print_objects(struct object_heap* oh, byte_t* memory, word_t memorySize);
00704 word_t heap_what_points_to_in(struct object_heap* oh, struct Object* x, byte_t* memory, word_t memorySize, bool_t print);
00705 word_t heap_what_points_to(struct object_heap* oh, struct Object* x, bool_t print);
00706 void heap_print_marks(struct object_heap* oh, byte_t* memory, word_t memorySize);
00707 void assert_good_object(struct object_heap* oh, struct Object* obj);
00708 void heap_integrity_check(struct object_heap* oh, byte_t* memory, word_t memorySize);
00709 struct Object* heap_new_cstring(struct object_heap* oh, byte_t *input);
00710 bool_t object_is_old(struct object_heap* oh, struct Object* oop);
00711 bool_t object_is_young(struct object_heap* oh, struct Object* obj);
00712 bool_t object_in_memory(struct object_heap* oh, struct Object* oop, byte_t* memory, word_t memorySize);
00713 struct Object* object_after(struct object_heap* heap, struct Object* o);
00714 bool_t object_is_marked(struct object_heap* heap, struct Object* o);
00715 bool_t object_is_free(struct Object* o);
00716 void method_flush_cache(struct object_heap* oh, struct Symbol* selector);
00717 struct Object* heap_make_free_space(struct object_heap* oh, struct Object* obj, word_t words);
00718 struct Object* heap_make_used_space(struct object_heap* oh, struct Object* obj, word_t words);
00719 bool_t heap_initialize(struct object_heap* oh, word_t size, word_t limit, word_t young_limit, word_t next_hash, word_t special_oop, word_t cdid);
00720 void heap_close(struct object_heap* oh);
00721 bool_t object_is_pinned(struct object_heap* oh, struct Object* x);
00722 bool_t object_is_remembered(struct object_heap* oh, struct Object* x);
00723 struct Object* heap_find_first_young_free(struct object_heap* oh, struct Object* obj, word_t bytes);
00724 struct Object* heap_find_first_old_free(struct object_heap* oh, struct Object* obj, word_t bytes);
00725 struct Object* gc_allocate_old(struct object_heap* oh, word_t bytes);
00726 struct Object* gc_allocate(struct object_heap* oh, word_t bytes);
00727 void object_forward_pointers_to(struct object_heap* oh, struct Object* o, struct Object* x, struct Object* y);
00728 void heap_free_object(struct object_heap* oh, struct Object* obj);
00729 void heap_finish_gc(struct object_heap* oh);
00730 void heap_finish_full_gc(struct object_heap* oh);
00731 void heap_start_gc(struct object_heap* oh);
00732 void heap_remember_old_object(struct object_heap* oh, struct Object* x);
00733 void heap_mark(struct object_heap* oh, struct Object* obj);
00734 void heap_mark_specials(struct object_heap* oh, bool_t mark_old);
00735 void heap_mark_fixed(struct object_heap* oh, bool_t mark_old);
00736 void heap_mark_interpreter_stack(struct object_heap* oh, bool_t mark_old);
00737 void heap_mark_fields(struct object_heap* oh, struct Object* o);
00738 void heap_mark_recursively(struct object_heap* oh, bool_t mark_old);
00739 void heap_free_and_coalesce_unmarked(struct object_heap* oh, byte_t* memory, word_t memorySize);
00740 void heap_unmark_all(struct object_heap* oh, byte_t* memory, word_t memorySize);
00741 void heap_update_forwarded_pointers(struct object_heap* oh, byte_t* memory, word_t memorySize);
00742 void heap_tenure(struct object_heap* oh);
00743 void heap_mark_remembered(struct object_heap* oh);
00744 void heap_mark_pinned_young(struct object_heap* oh);
00745 void heap_mark_pinned_old(struct object_heap* oh);
00746 void heap_full_gc(struct object_heap* oh);
00747 void heap_gc(struct object_heap* oh);
00748 void heap_forward_from(struct object_heap* oh, struct Object* x, struct Object* y, byte_t* memory, word_t memorySize);
00749 void heap_forward(struct object_heap* oh, struct Object* x, struct Object* y);
00750 void heap_store_into(struct object_heap* oh, struct Object* src, struct Object* dest);
00751 struct Object* heap_allocate_with_payload(struct object_heap* oh, word_t words, word_t payload_size);
00752 struct Object* heap_allocate(struct object_heap* oh, word_t words);
00753 struct Object* heap_clone(struct object_heap* oh, struct Object* proto);
00754 struct Object* heap_clone_special(struct object_heap* oh, word_t special_index);
00755 struct Map* heap_clone_map(struct object_heap* oh, struct Map* map);
00756 struct ByteArray* heap_new_float(struct object_heap* oh);
00757 struct OopArray* heap_clone_oop_array_sized(struct object_heap* oh, struct Object* proto, word_t size);
00758 struct ByteArray* heap_clone_byte_array_sized(struct object_heap* oh, struct Object* proto, word_t bytes);
00759 struct ByteArray* heap_new_byte_array_with(struct object_heap* oh, word_t byte_size, byte_t* bytes);
00760 struct ByteArray* heap_new_string_with(struct object_heap* oh, word_t byte_size, byte_t* bytes);
00761 void interpreter_grow_stack(struct object_heap* oh, struct Interpreter* i, word_t minimum);
00762 void interpreter_stack_allocate(struct object_heap* oh, struct Interpreter* i, word_t n);
00763 void interpreter_stack_push(struct object_heap* oh, struct Interpreter* i, struct Object* value);
00764 struct Object* interpreter_stack_pop(struct object_heap* oh, struct Interpreter* i);
00765 void interpreter_stack_pop_amount(struct object_heap* oh, struct Interpreter* i, word_t amount);
00766 void unhandled_signal(struct object_heap* oh, struct Symbol* selector, word_t n, struct Object* args[]);
00767 void interpreter_signal(struct object_heap* oh, struct Interpreter* i, struct Object* signal, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00768 void interpreter_signal_with(struct object_heap* oh, struct Interpreter* i, struct Object* signal, struct Object* arg, struct OopArray* opts, word_t resultStackPointer);
00769 void interpreter_signal_with_with(struct object_heap* oh, struct Interpreter* i, struct Object* signal, struct Object* arg, struct Object* arg2, struct OopArray* opts, word_t resultStackPointer);
00770 void interpreter_signal_with_with_with(struct object_heap* oh, struct Interpreter* i, struct Object* signal, struct Object* arg, struct Object* arg2, struct Object* arg3, struct OopArray* opts, word_t resultStackPointer);
00771 bool_t interpreter_dispatch_optional_keyword(struct object_heap* oh, struct Interpreter * i, struct Object* key, struct Object* value);
00772 void interpreter_dispatch_optionals(struct object_heap* oh, struct Interpreter * i, struct OopArray* opts);
00773 bool_t interpreter_return_result(struct object_heap* oh, struct Interpreter* i, word_t context_depth, struct Object* result, word_t prevCodePointer);
00774 void interpreter_resend_message(struct object_heap* oh, struct Interpreter* i, word_t n, word_t resultStackPointer);
00775 void interpreter_branch_keyed(struct object_heap* oh, struct Interpreter * i, struct OopArray* table, struct Object* oop);
00776 void interpret(struct object_heap* oh);
00777 void method_save_cache(struct object_heap* oh, struct MethodDefinition* md, struct Symbol* name, struct Object* arguments[], word_t n);
00778 struct MethodDefinition* method_check_cache(struct object_heap* oh, struct Symbol* selector, struct Object* arguments[], word_t n);
00779 void method_unoptimize(struct object_heap* oh, struct CompiledMethod* method);
00780 void method_remove_optimized_sending(struct object_heap* oh, struct Symbol* symbol);
00781 void method_optimize(struct object_heap* oh, struct CompiledMethod* method);
00782 void method_pic_setup(struct object_heap* oh, struct CompiledMethod* caller);
00783 void method_pic_flush_caller_pics(struct object_heap* oh, struct CompiledMethod* callee);
00784 struct MethodDefinition* method_is_on_arity(struct object_heap* oh, struct Object* method, struct Symbol* selector, struct Object* args[], word_t n);
00785 struct MethodDefinition* method_define(struct object_heap* oh, struct Object* method, struct Symbol* selector, struct Object* args[], word_t n);
00786 void error(const char* str);
00787 void cache_specials(struct object_heap* heap);
00788 #ifndef WIN32
00789 word_t max(word_t x, word_t y);
00790 #endif
00791 word_t write_args_into(struct object_heap* oh, char* buffer, word_t limit);
00792 word_t hash_selector(struct object_heap* oh, struct Symbol* name, struct Object* arguments[], word_t n);
00793 void object_set_mark(struct object_heap* oh, struct Object* xxx);
00794 void object_unmark(struct object_heap* oh, struct Object* xxx) ;
00795 void object_set_format(struct Object* xxx, word_t type);
00796 void object_set_size(struct Object* xxx, word_t size);
00797 void object_set_idhash(struct Object* xxx, word_t hash);
00798 void payload_set_size(struct Object* xxx, word_t size);
00799 word_t heap_new_hash(struct object_heap* oh);
00800 struct Object* get_special(struct object_heap* oh, word_t special_index);
00801 struct Map* object_get_map(struct object_heap* oh, struct Object* o);
00802 word_t object_word_size(struct Object* o);
00803 word_t object_array_offset(struct Object* o);
00804 struct Object* object_array_get_element(struct Object* o, word_t i);
00805 struct Object* object_array_set_element(struct object_heap* oh, struct Object* o, word_t i, struct Object* val);
00806 struct Object** object_array_elements(struct Object* o);
00807 struct Object** array_elements(struct OopArray* o);
00808 word_t object_array_size(struct Object* o);
00809 word_t byte_array_size(struct ByteArray* o);
00810 word_t array_size(struct OopArray* x);
00811 word_t slot_table_capacity(struct SlotTable* roles);
00812 word_t role_table_capacity(struct RoleTable* roles);
00813 word_t object_byte_size(struct Object* o);
00814 word_t object_total_size(struct Object* o);
00815 word_t object_first_slot_offset(struct Object* o);
00816 word_t object_last_slot_offset(struct Object* o);
00817 word_t object_last_oop_offset(struct Object* o);
00818 struct Object* object_slot_value_at_offset(struct Object* o, word_t offset);
00819 struct Object* object_slot_value_at_offset_put(struct object_heap* oh, struct Object* o, word_t offset, struct Object* value);
00820 struct RoleEntry* role_table_entry_for_name(struct object_heap* oh, struct RoleTable* roles, struct Symbol* name);
00821 struct RoleEntry* role_table_entry_for_inserting_name(struct object_heap* oh, struct RoleTable* roles, struct Symbol* name);
00822 struct RoleEntry* role_table_insert(struct object_heap* oh, struct RoleTable* roles, struct Symbol* name);
00823 struct SlotEntry* slot_table_entry_for_name(struct object_heap* oh, struct SlotTable* slots, struct Symbol* name);
00824 struct SlotEntry* slot_table_entry_for_inserting_name(struct object_heap* oh, struct SlotTable* slots, struct Symbol* name);
00825 word_t role_table_accommodate(struct RoleTable* roles, word_t n);
00826 word_t slot_table_accommodate(struct SlotTable* roles, word_t n);
00827 word_t role_table_empty_space(struct object_heap* oh, struct RoleTable* roles);
00828 word_t slot_table_empty_space(struct object_heap* oh, struct SlotTable* slots);
00829 struct RoleTable* role_table_grow_excluding(struct object_heap* oh, struct RoleTable* roles, word_t n, struct MethodDefinition* method);
00830 struct SlotTable* slot_table_grow_excluding(struct object_heap* oh, struct SlotTable* slots, word_t n, struct Symbol* excluding);
00831 void slot_table_relocate_by(struct object_heap* oh, struct SlotTable* slots, word_t offset, word_t amount);
00832 struct MethodDefinition* object_has_role_named_at(struct Object* obj, struct Symbol* selector, word_t position, struct Object* method);
00833 void object_change_map(struct object_heap* oh, struct Object* obj, struct Map* map);
00834 void object_represent(struct object_heap* oh, struct Object* obj, struct Map* map);
00835 word_t object_add_role_at(struct object_heap* oh, struct Object* obj, struct Symbol* selector, word_t position, struct MethodDefinition* method);
00836 word_t object_remove_role(struct object_heap* oh, struct Object* obj, struct Symbol* selector, struct MethodDefinition* method);
00837 struct Object* object_add_slot_named_at(struct object_heap* oh, struct Object* obj, struct Symbol* name, struct Object* value, word_t offset);
00838 struct Object* object_add_slot_named(struct object_heap* oh, struct Object* obj, struct Symbol* name, struct Object* value);
00839 struct Object* object_remove_slot(struct object_heap* oh, struct Object* obj, struct Symbol* name);
00840 void adjust_fields_by(struct object_heap* oh, struct Object* o, word_t shift_amount);
00841 void adjust_oop_pointers_from(struct object_heap* oh, word_t shift_amount, byte_t* memory, word_t memorySize);
00842 void prim_fixme(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00843 void prim_closePipe(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00844 void prim_readFromPipe(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00845 void prim_writeToPipe(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00846 void prim_selectOnWritePipesFor(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00847 void prim_cloneSystem(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00848 void prim_socketCreate(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00849 void prim_socketListen(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00850 void prim_socketAccept(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00851 void prim_socketBind(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00852 void prim_socketConnect(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00853 void prim_socketGetError(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00854 void prim_getAddrInfo(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00855 void prim_getAddrInfoResult(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00856 void prim_freeAddrInfoResult(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00857 void prim_socketCreateIP(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00858 void prim_write_to_starting_at(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00859 void prim_close(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00860 void prim_readConsole_from_into_starting_at(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00861 void prim_read_from_into_starting_at(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00862 void prim_write_to_from_starting_at(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00863 void prim_reposition_to(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00864 void prim_positionOf(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00865 void prim_bytesPerWord(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00866 void prim_timeSinceEpoch(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00867 void prim_atEndOf(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00868 void prim_sizeOf(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00869 void prim_flush_output(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00870 void prim_handle_for(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00871 void prim_handleForNew(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00872 void prim_handle_for_input(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00873 void prim_addressOf(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00874 void prim_library_open(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00875 void prim_library_close(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00876 void prim_procAddressOf(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00877 void prim_extlibError(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00878 void prim_applyExternal(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00879 void prim_memory_new(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00880 void prim_memory_close(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00881 void prim_memory_size(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00882 void prim_memory_addRef(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00883 void prim_memory_read(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00884 void prim_memory_write(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00885 void prim_memory_resizeTo(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00886 void prim_smallint_at_slot_named(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00887 void prim_bytesize(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00888 void prim_findon(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00889 void prim_ensure(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00890 void prim_frame_pointer_of(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00891 void prim_bytearray_newsize(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00892 void prim_byteat_put(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00893 void prim_byteat(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00894 void prim_map(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00895 void prim_set_map(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00896 void prim_run_args_into(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00897 void prim_exit(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00898 void prim_isIdenticalTo(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00899 void prim_identity_hash(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00900 void prim_identity_hash_univ(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00901 void prim_clone(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00902 void prim_applyto(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* optionals, word_t resultStackPointer);
00903 void prim_at(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00904 void prim_at_put(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00905 void prim_ooparray_newsize(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00906 void prim_equals(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00907 void prim_less_than(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00908 void prim_size(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00909 void prim_bitand(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00910 void prim_bitor(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00911 void prim_bitxor(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00912 void prim_bitnot(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00913 void prim_smallIntegerMinimum(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00914 void prim_smallIntegerMaximum(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00915 void prim_plus(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00916 void prim_removefrom(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00917 void prim_exponent(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00918 void prim_significand(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00919 void prim_getcwd(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00920 void prim_setcwd(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00921 void prim_float_equals(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00922 void prim_float_less_than(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00923 void prim_float_plus(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00924 void prim_float_minus(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00925 void prim_float_times(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00926 void prim_float_divide(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00927 void prim_float_raisedTo(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00928 void prim_float_ln(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00929 void prim_float_exp(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00930 void prim_float_sin(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00931 void prim_withSignificand_exponent(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00932 void prim_bitshift(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00933 void prim_minus(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00934 void prim_times(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00935 void prim_quo(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00936 void prim_forward_to(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00937 void prim_clone_setting_slots(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00938 void prim_as_method_on(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00939 void prim_at_slot_named(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00940 void prim_at_slot_named_put(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00941 void prim_clone_with_slot_valued(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00942 void prim_clone_without_slot(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00943 void prim_send_to(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* optionals, word_t resultStackPointer);
00944 void prim_send_to_through(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* optionals, word_t resultStackPointer);
00945 void prim_as_accessor(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00946 void prim_save_image(struct object_heap* oh, struct Object* args[], word_t n, struct OopArray* opts, word_t resultStackPointer);
00947
00948 void socket_module_init(struct object_heap* oh);
00949 word_t socket_return(word_t ret);
00950 int socket_select_setup(struct OopArray* selectOn, fd_set* fdList, int* maxFD);
00951 void socket_select_find_available(struct OopArray* selectOn, fd_set* fdList, struct OopArray* readyPipes, word_t readyCount);
00952 void prim_selectOnReadPipesFor(struct object_heap* oh, struct Object* args[], word_t arity, struct OopArray* opts, word_t resultStackPointer);
00953 int socket_lookup_domain(word_t domain);
00954 int socket_reverse_lookup_domain(word_t domain);
00955 int socket_lookup_type(word_t type);
00956 int socket_reverse_lookup_type(word_t type);
00957 int socket_lookup_protocol(word_t protocol);
00958 int socket_reverse_lookup_protocol(word_t protocol);
00959 int socket_getaddrinfo(struct object_heap* oh, struct ByteArray* hostname, word_t hostnameSize, struct ByteArray* service, word_t serviceSize, word_t family, word_t type, word_t protocol, word_t flags);
00960
00961 word_t memory_string_to_bytes(char* str);
00962
00963 byte_t* byte_array_elements(struct ByteArray* o);
00964 byte_t byte_array_get_element(struct Object* o, word_t i);
00965 byte_t byte_array_set_element(struct ByteArray* o, word_t i, byte_t val);
00966 int fork2();
00967 word_t calculateMethodCallDepth(struct object_heap* oh);
00968
00969
00970 void file_module_init(struct object_heap* oh);
00971 bool_t file_handle_isvalid(struct object_heap* oh, word_t file);
00972 word_t file_allocate(struct object_heap* oh);
00973 void file_close(struct object_heap* oh, word_t file);
00974 word_t file_open(struct object_heap* oh, struct ByteArray * name, word_t flags);
00975 word_t file_write(struct object_heap* oh, word_t file, word_t n, char * bytes);
00976 word_t file_read(struct object_heap* oh, word_t file, word_t n, char * bytes);
00977 word_t file_sizeof(struct object_heap* oh, word_t file);
00978 word_t file_seek(struct object_heap* oh, word_t file, word_t offset);
00979 word_t file_tell(struct object_heap* oh, word_t file);
00980 bool_t file_isatend(struct object_heap* oh, word_t file);
00981 bool_t file_delete(struct object_heap* oh, char* filename);
00982 struct Object* file_information(struct object_heap* oh, char* filename);
00983 bool_t file_rename_to(struct object_heap* oh, char* src, char* dest);
00984
00985
00986 void dir_module_init(struct object_heap* oh);
00987 int dir_open(struct object_heap* oh, struct ByteArray *dirName);
00988 int dir_close(struct object_heap* oh, int dirHandle);
00989 int dir_read(struct object_heap* oh, int dirHandle, struct ByteArray *entNameBuffer);
00990 int dir_getcwd(struct ByteArray *wdBuffer);
00991 int dir_setcwd(struct ByteArray *newWd);
00992 bool_t dir_make(struct object_heap* oh, char* dir);
00993 bool_t dir_delete(struct object_heap* oh, char* dir);
00994 bool_t dir_rename_to(struct object_heap* oh, char* src, char* dest);
00995
00996
00997
00998 void memarea_module_init (struct object_heap* oh);
00999 int memarea_handle_isvalid (struct object_heap* oh, int memory);
01000 void memarea_close (struct object_heap* oh, int memory);
01001 void memarea_addref (struct object_heap* oh, int memory);
01002 int memarea_open (struct object_heap* oh, int size);
01003 int memarea_write (struct object_heap* oh, int memory, int memStart, int n, byte_t* bytes);
01004 int memarea_read (struct object_heap* oh, int memory, int memStart, int n, byte_t* bytes);
01005 int memarea_sizeof (struct object_heap* oh, int memory);
01006 int memarea_resize (struct object_heap* oh, int memory, int size);
01007 int memarea_addressof (struct object_heap* oh, int memory, int offset, byte_t* addressBuffer);
01008
01009 void profiler_start(struct object_heap* oh);
01010 void profiler_stop(struct object_heap* oh);
01011 void profiler_enter_method(struct object_heap* oh, struct Object* fromMethod, struct Object* toMethod, bool_t push);
01012 void profiler_delete_method(struct object_heap* oh, struct Object* method);
01013 void heap_notice_forwarded_object(struct object_heap* oh, struct Object* from, struct Object* to);
01014 void profiler_notice_forwarded_object(struct object_heap* oh, struct Object* from, struct Object* to);
01015
01016 bool_t openExternalLibrary(struct object_heap* oh, struct ByteArray *libname, struct ByteArray *handle);
01017 bool_t closeExternalLibrary(struct object_heap* oh, struct ByteArray *handle);
01018 bool_t lookupExternalLibraryPrimitive(struct object_heap* oh, struct ByteArray *handle, struct ByteArray *symname, struct ByteArray *ptr);
01019 int readExternalLibraryError(struct ByteArray *messageBuffer);
01020 word_t extractBigInteger(struct ByteArray* bigInt);
01021 struct Object* injectBigInteger(struct object_heap* oh, word_t value);
01022 struct Object* heap_new_cstring(struct object_heap* oh, byte_t *input);
01023 struct Object* applyExternalLibraryPrimitive(struct object_heap* oh, struct ByteArray * fnHandle, struct OopArray * argsFormat, struct Object* callFormat, struct Object* resultFormat, struct OopArray * argsArr);
01024
01025 struct MethodDefinition* method_dispatch_on(struct object_heap* oh, struct Symbol* name,
01026 struct Object* arguments[], word_t arity, struct Object* resendMethod);
01027
01028 word_t object_is_immutable(struct Object* o);
01029 word_t smallint_fits_object(word_t i);
01030 float_type* float_part(struct ByteArray* o);
01031 void copy_used_objects(struct object_heap* oh, struct Object** writeObject, byte_t* memoryStart, word_t memorySize,
01032 struct ForwardPointerEntry* table, word_t forwardPointerEntryCount);
01033
01034 void adjust_object_fields_with_table(struct object_heap* oh, byte_t* memory, word_t memorySize,
01035 struct ForwardPointerEntry* table, word_t forwardPointerEntryCount);
01036
01037
01038 struct ForwardPointerEntry* forward_pointer_hash_add(struct ForwardPointerEntry* table,
01039 word_t forwardPointerEntryCount,
01040 struct Object* fromObj, struct Object* toObj);
01041
01042 struct ForwardPointerEntry* forward_pointer_hash_get(struct ForwardPointerEntry* table,
01043 word_t forwardPointerEntryCount,
01044 struct Object* fromObj);
01045
01046
01047 int socket_set_nonblocking(int fd);
01048
01049 word_t extractCString(struct ByteArray * array, byte_t* buffer, word_t bufferSize);
01050
01051
01052 struct MethodDefinition* method_pic_find_callee(struct object_heap* oh, struct CompiledMethod* callerMethod,
01053 struct Symbol* selector, word_t arity, struct Object* args[]);
01054
01055 void method_pic_add_callee(struct object_heap* oh, struct CompiledMethod* callerMethod, struct MethodDefinition* def,
01056 word_t arity, struct Object* args[]);
01057
01058
01059
01060
01061 void method_pic_add_callee_backreference(struct object_heap* oh,
01062 struct CompiledMethod* caller, struct CompiledMethod* callee);
01063
01064
01065
01066
01067 void print_code_disassembled(struct object_heap* oh, struct OopArray* code);
01068 void print_pic_entries(struct object_heap* oh, struct CompiledMethod* method);
01069
01070
01071
01072
01073 word_t opcode_length(std::vector<struct Object*>& code, word_t start);
01074 word_t opcode_base_length(word_t rawop);
01075 word_t opcode_arg_length(std::vector<struct Object*>& code, word_t start);
01076 word_t opcode_register_locations(word_t rawop);
01077 void optimizer_offset_registers(std::vector<struct Object*>& code, int offset);
01078 void optimizer_append_code_to_vector(struct OopArray* code, std::vector<struct Object*>& vector);
01079 void optimizer_insert_code(std::vector<struct Object*>& code, size_t offset, std::vector<struct Object*>& newCode);
01080 void optimizer_delete_code(std::vector<struct Object*>& code, size_t offset, word_t amount);
01081 void optimizer_inline_callees(struct object_heap* oh, struct CompiledMethod* method);
01082 bool optimizer_method_can_be_optimized(struct object_heap* oh, struct CompiledMethod* method);
01083 bool optimizer_method_can_be_inlined(struct object_heap* oh, struct CompiledMethod* method);
01084 void print_code(struct object_heap* oh, std::vector<struct Object*> code);
01085
01086
01087
01088 void heap_pin_object(struct object_heap* oh, struct Object* x);
01089 void heap_unpin_object(struct object_heap* oh, struct Object* x);
01090
01091 template <class T> class Pinned {
01092
01093 private:
01094 Pinned() {}
01095
01096 public:
01097 T* value;
01098 struct object_heap* oh;
01099 Pinned(struct object_heap* oh_) : value(0), oh(oh_) { }
01100 Pinned(struct object_heap* oh_, T* v) : value(v), oh(oh_) {
01101 heap_pin_object(oh, (struct Object*)value);
01102 }
01103
01104 Pinned(const Pinned<T>& v) : value(v.value), oh(v.oh) {
01105 if (value != NULL) {
01106 heap_pin_object(oh, (struct Object*)value);
01107 }
01108 }
01109
01110
01111 T* operator ->() {
01112 #ifdef GC_BUG_CHECK
01113
01114 assert(object_hash((struct Object*)value) < ID_HASH_RESERVED);
01115
01116 #endif
01117 return value;
01118 }
01119
01120 ~Pinned() {
01121 if (value != 0) {
01122 heap_unpin_object(oh, (struct Object*)value);
01123 }
01124 }
01125 operator struct Object* () {
01126 return (struct Object*)value;
01127 }
01128 operator struct RoleTable* () {return (struct RoleTable*)value;}
01129 operator struct SlotTable* () {return (struct SlotTable*)value;}
01130 operator byte_t* () {return (byte_t*)value;}
01131 operator struct Map* () {return (struct Map*)value;}
01132 operator struct OopArray* () {return (struct OopArray*)value;}
01133 operator struct Interpreter* () {return (struct Interpreter*)value;}
01134 operator struct ByteArray* () {return (struct ByteArray*)value;}
01135 operator struct CompiledMethod* () {return (struct CompiledMethod*)value;}
01136 operator struct MethodDefinition* () {return (struct MethodDefinition*)value;}
01137 operator struct Closure* () {return (struct Closure*)value;}
01138 operator struct Symbol* () {return (struct Symbol*)value;}
01139 operator struct LexicalContext* () {return (struct LexicalContext*)value;}
01140 operator struct PrimitiveMethod* () {return (struct PrimitiveMethod*)value;}
01141 const Pinned<T>& operator=(T *v) {
01142 if (v != value) {
01143 if (v != NULL) {
01144 heap_pin_object(oh, (struct Object*)v);
01145 }
01146 if (value != 0) {
01147 heap_unpin_object(oh, (struct Object*)value);
01148 }
01149 }
01150 value = v;
01151 return *this;
01152 }
01153
01154 };
01155
01156 #include "inline.hpp"
01157
01158
01159
01160