00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 # include "incls/_precompiled.incl"
00025 # include "incls/_oop_prims.cpp.incl"
00026 
00027 TRACE_FUNC(TraceOopPrims, "oop")
00028 
00029 int oopPrimitives::number_of_calls;
00030 
00031 PRIM_DECL_2(oopPrimitives::become, oop receiver, oop argument){
00032   PROLOGUE_2("become", receiver, argument)
00033   PRIM_NOT_IMPLEMENTED
00034 }
00035 
00036 PRIM_DECL_2(oopPrimitives::instVarAt, oop receiver, oop index) {
00037   PROLOGUE_2("instVarAt", receiver, index)
00038   if (!receiver->is_mem())
00039     return markSymbol(vmSymbols::receiver_has_wrong_type());
00040   if (!index->is_smi())
00041     return markSymbol(vmSymbols::first_argument_has_wrong_type());
00042 
00043   int raw_index = smiOop(index)->value() - 1;
00044 
00045   if (!memOop(receiver)->is_within_instVar_bounds(raw_index))
00046     markSymbol(vmSymbols::out_of_bounds());
00047 
00048   return memOop(receiver)->instVarAt(raw_index);
00049 }
00050 
00051 PRIM_DECL_2(oopPrimitives::instance_variable_name_at, oop obj, oop index) {
00052   PROLOGUE_2("instance_variable_name_at", obj, index)
00053   if (!obj->is_mem())
00054     return markSymbol(vmSymbols::receiver_has_wrong_type());
00055   if (!index->is_smi())
00056     return markSymbol(vmSymbols::first_argument_has_wrong_type());
00057 
00058   int raw_index = smiOop(index)->value() - 1;
00059 
00060   if (!memOop(obj)->is_within_instVar_bounds(raw_index))
00061     markSymbol(vmSymbols::out_of_bounds());
00062 
00063   return obj->blueprint()->inst_var_name_at(raw_index);
00064 }
00065 
00066 PRIM_DECL_3(oopPrimitives::instVarAtPut, oop receiver, oop index, oop value) {
00067   PROLOGUE_3("instVarAtPut", receiver, index, value)
00068   if (!receiver->is_mem())
00069     return markSymbol(vmSymbols::receiver_has_wrong_type());
00070   if (!index->is_smi())
00071     return markSymbol(vmSymbols::first_argument_has_wrong_type());
00072 
00073   int raw_index = smiOop(index)->value() - 1;
00074 
00075   if (!memOop(receiver)->is_within_instVar_bounds(raw_index))
00076     markSymbol(vmSymbols::out_of_bounds());
00077 
00078   return memOop(receiver)->instVarAtPut(raw_index, value);
00079 }
00080 
00081 PRIM_DECL_1(oopPrimitives::hash, oop receiver) {
00082   PROLOGUE_1("hash", receiver)
00083   return as_smiOop(receiver->identity_hash());
00084 }
00085 
00086 PRIM_DECL_1(oopPrimitives::hash_of, oop obj) {
00087   PROLOGUE_1("hash_of", obj)
00088   return as_smiOop(obj->identity_hash());
00089 }
00090 
00091 PRIM_DECL_1(oopPrimitives::shallowCopy, oop receiver) {
00092   PROLOGUE_1("shallowCopy", receiver)
00093   return receiver->shallow_copy(false);
00094 }
00095 
00096 PRIM_DECL_1(oopPrimitives::copy_tenured, oop receiver) {
00097   PROLOGUE_1("copy_tenured", receiver)
00098   return receiver->shallow_copy(true);
00099 }
00100 
00101 PRIM_DECL_2(oopPrimitives::equal, oop receiver, oop argument){ 
00102   PROLOGUE_2("equal", receiver, argument)
00103   return receiver == argument ? trueObj : falseObj;
00104 }
00105 
00106 PRIM_DECL_2(oopPrimitives::not_equal, oop receiver, oop argument){ 
00107   PROLOGUE_2("not_equal", receiver, argument)
00108   return receiver != argument ? trueObj : falseObj;
00109 }
00110 
00111 PRIM_DECL_1(oopPrimitives::oop_size, oop receiver) {
00112   PROLOGUE_1("oop_size", receiver)
00113   return as_smiOop(receiver->is_mem() ? memOop(receiver)->size() : 0);
00114 }
00115 
00116 PRIM_DECL_1(oopPrimitives::klass, oop receiver) {
00117   PROLOGUE_1("klass", receiver)
00118   return receiver->klass();
00119 }
00120 
00121 PRIM_DECL_1(oopPrimitives::klass_of, oop obj) {
00122   PROLOGUE_1("klass_of", obj)
00123   return obj->klass();
00124 }
00125 
00126 PRIM_DECL_1(oopPrimitives::print, oop receiver) {
00127   PROLOGUE_1("print", receiver)
00128   ResourceMark rm;
00129   receiver->print();
00130   return receiver;
00131 }
00132 
00133 PRIM_DECL_1(oopPrimitives::printValue, oop receiver) {
00134   PROLOGUE_1("printString", receiver)
00135   ResourceMark rm;
00136   receiver->print_value();
00137   return receiver;
00138 }
00139 
00140 PRIM_DECL_1(oopPrimitives::asObjectID, oop receiver) {
00141   PROLOGUE_1("asObjectID", receiver)
00142   return smiOop(objectIDTable::insert(receiver)); 
00143 }
00144 
00145 PRIM_DECL_2(oopPrimitives::perform, oop receiver, oop selector) {
00146   PROLOGUE_2("perform", receiver, selector);
00147   return Delta::call(receiver, selector);
00148 }
00149 
00150 PRIM_DECL_3(oopPrimitives::performWith, oop receiver, oop selector, oop arg1) {
00151   PROLOGUE_3("performWith", receiver, selector, arg1);
00152   return Delta::call(receiver, selector, arg1);
00153 }
00154 
00155 PRIM_DECL_4(oopPrimitives::performWithWith, oop receiver, oop selector, oop arg1, oop arg2) {
00156   PROLOGUE_4("performWithWith", receiver, selector, arg1, arg2);
00157   return Delta::call(receiver, selector, arg1, arg2);
00158 }
00159 
00160 PRIM_DECL_5(oopPrimitives::performWithWithWith, oop receiver, oop selector, oop arg1, oop arg2, oop arg3) {
00161   PROLOGUE_5("performWithWithWith", receiver, selector, arg1, arg2, arg3);
00162   return Delta::call(receiver, selector, arg1, arg2, arg3);
00163 }
00164 
00165 PRIM_DECL_3(oopPrimitives::performArguments, oop receiver, oop selector, oop args) {
00166   PROLOGUE_3("performArguments", receiver, selector, args);
00167   if (!args->is_objArray())
00168     return markSymbol(vmSymbols::third_argument_has_wrong_type());
00169   return Delta::call(receiver, selector, objArrayOop(args));
00170 }