Example #1
0
void AbstractByteCode::GenSendByteCode( fint offset, fint length,
                                        stringOop selector, 
                                        bool isSelfImplicit,
                                        bool isUndirectedResend, 
                                        stringOop resendTarget) {
                                        
  if (resendTarget != NULL) {
    GenDelegateeByteCode(offset, length, resendTarget);
  }
  else if ( isUndirectedResend )
     GenUndirectedResendByteCode(offset, length);

  fint argc = selector->arg_count();
  if (GenArgCountBytecode  &&  argc != 0)
    GenCode(offset, length, 
            BuildCode( ARGUMENT_COUNT_CODE, 
                       GenIndex(offset, length, argc)));
    
  GenCode(offset, length,
          BuildCode( isSelfImplicit ? IMPLICIT_SEND_CODE : SEND_CODE, 
                     GenIndex(offset, length,
                              GenLiteral(selector))));
                              
  if (!isSelfImplicit)
    --stack_depth;
  stack_depth -= argc;
  assert(stack_depth >= 0, "negative stack?");
  ++stack_depth;
}
Example #2
0
 void SCodeScope::memoizeBlocks(stringOop sel) {
   // memoize block args so they aren't created for inlined cases
   fint top = exprStack->length();
   fint argc = sel->arg_count();
   for (fint i = 1; i <= argc; i++) {
     PReg* r = exprStack->nth(top - i)->preg();
     if (r->isBlockPReg()) ((BlockPReg*)r)->memoize();
   }
 }
Example #3
0
oop slotsMap::copy_add_method_slot( slotsOop obj,
                                    stringOop name, 
                                    slotType type, 
                                    oop contents,
                                    oop anno,
                                    bool mustAllocate) {

  if (type->is_vm_slot()) {
    // skip all the checks and do not try to remove it, since
    // vm slots do not change from obj to map, and rm will fetch anyway
    slotDesc* sd = obj->find_slot(name);
    return sd != NULL
     ? change_slot      (obj, sd,   type, contents, anno, mustAllocate)
     : copy_add_new_slot(obj, name, type, contents, anno, mustAllocate);
  }
  if ( contents->arg_count() != name->arg_count() )
    return ErrorCodes::vmString_prim_error(ARGUMENTCOUNTERROR);

  if (obj->is_method_like())
    return ErrorCodes::vmString_prim_error(BADTYPEERROR); // cannot add methods to methods

  slotDesc *old= find_slot(name);
  if (old && old->is_map_slot())
    // change in situ
    return change_slot(obj, old, type, contents, anno, mustAllocate);

  slotsOop result;
  if (old) {
    // remove the old slot, then add in a new one
    result= (slotsOop)copy_remove_one_slot(obj, old, mustAllocate);
    if (oop(result) == failedAllocationOop) return failedAllocationOop;

    if (old->is_assignment_slot_name(name)) {
      // replace the data slot as a map slot
      result= ((slotsMap*)result->map())->
        copy_add_new_slot(result, old->name, MAP_SLOT(old->type),
                          obj->get_slot(old), old->annotation, mustAllocate);
      if (oop(result) == failedAllocationOop) return failedAllocationOop;
    }
  } else
    result= obj;

  return ((slotsMap*)result->map())->
    copy_add_new_slot(result, name, MAP_SLOT(type), contents, anno,
                      mustAllocate);
}