address JNI_FastGetField::generate_fast_get_float_field0(BasicType type) {
  const char *name;
  switch (type) {
    case T_FLOAT:  name = "jni_fast_GetFloatField";  break;
    case T_DOUBLE: name = "jni_fast_GetDoubleField"; break;
    default:       ShouldNotReachHere();
  }
  ResourceMark rm;
  BufferBlob* blob = BufferBlob::create(name, BUFFER_SIZE*wordSize);
  CodeBuffer cbuf(blob);
  MacroAssembler* masm = new MacroAssembler(&cbuf);
  address fast_entry = __ pc();

  Label label1, label2;

  AddressLiteral cnt_addrlit(SafepointSynchronize::safepoint_counter_addr());
  __ sethi (cnt_addrlit, O3);
  Address cnt_addr(O3, cnt_addrlit.low10());
  __ ld (cnt_addr, G4);
  __ andcc (G4, 1, G0);
  __ br (Assembler::notZero, false, Assembler::pn, label1);
  __ delayed()->srl (O2, 2, O4);
  __ ld_ptr (O1, 0, O5);

  assert(count < LIST_CAPACITY, "LIST_CAPACITY too small");
  speculative_load_pclist[count] = __ pc();
  switch (type) {
    case T_FLOAT:  __ ldf (FloatRegisterImpl::S, O5, O4, F0); break;
    case T_DOUBLE: __ ldf (FloatRegisterImpl::D, O5, O4, F0); break;
    default:       ShouldNotReachHere();
  }

  __ ld (cnt_addr, O5);
  __ cmp (O5, G4);
  __ br (Assembler::notEqual, false, Assembler::pn, label2);
  __ delayed()->mov (O7, G1);

  __ retl ();
  __ delayed()-> nop ();

  slowcase_entry_pclist[count++] = __ pc();
  __ bind (label1);
  __ mov (O7, G1);

  address slow_case_addr;
  switch (type) {
    case T_FLOAT:  slow_case_addr = jni_GetFloatField_addr();  break;
    case T_DOUBLE: slow_case_addr = jni_GetDoubleField_addr(); break;
    default:       ShouldNotReachHere();
  }
  __ bind (label2);
  __ call (slow_case_addr, relocInfo::none);
  __ delayed()->mov (G1, O7);

  __ flush ();

  return fast_entry;
}
inline void MacroAssembler::ldf(FloatRegisterImpl::Width w, const Address& a, FloatRegister d, int offset) {
  relocate(a.rspec(offset));
  if (a.has_index()) {
    assert(offset == 0, "");
    ldf(w, a.base(), a.index(), d);
  } else {
    ldf(w, a.base(), a.disp() + offset, d);
  }
}
예제 #3
0
void getmail()          /* Logs on to mail server to send spooled mail and */
			/* collect any new mail in MAILDIR.  Reads through */
			/* new mail, formatting each message individually, */
			/* storing the output bit-map file in MESSDIR and  */
			/* spooling the acknowledgement file ready for     */
			/* sending next time getmail is called.            */

			/* 20/3/90, 21/3/90  R J Finean */

{
  char txt[MAXLINELEN];         /* Miscellaneous text */
  FILE *mfp;                    /* Mailbox file pointer */

  system(EXEDIR "uuio -x0");   /* Send old acknowledgenents & get new mail */
  remove(SPOOLDIR "logfile");

  if (mfp = fopen(MAILBOX, "rt"))
    {
      fgets(txt, MAXLINELEN, mfp);     /* Ignore first line, only a header */
      while (!feof(mfp))
	  /* Process one message at a time */
	  if (!ldf(mfp))
	      break;
      fclose(mfp);
      remove(MAILBOX);
    }
}
void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {
  Argument  jni_arg(jni_offset(), false);
#ifdef _LP64
  FloatRegister  Rtmp = F0;
  __ ldf(FloatRegisterImpl::S, Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp);
  __ store_float_argument(Rtmp, jni_arg);
#else
  Register     Rtmp = O0;
  __ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp);
  __ store_argument(Rtmp, jni_arg);
#endif
}
void InterpreterRuntime::SignatureHandlerGenerator::pass_double() {
  Argument  jni_arg(jni_offset(), false);
#ifdef _LP64
  FloatRegister  Rtmp = F0;
  __ ldf(FloatRegisterImpl::D, Llocals, -(offset() + 1) * wordSize, Rtmp);
  __ store_double_argument(Rtmp, jni_arg);
#else
  Register  Rtmp = O0;
  __ ld(Llocals, -(offset() + 1) * wordSize, Rtmp);
  __ store_argument(Rtmp, jni_arg);
  __ ld(Llocals, -offset() * wordSize, Rtmp);
  __ store_argument(Rtmp, jni_arg.successor());
#endif
}
예제 #6
0
static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) {
  for (int i = 0; i < FrameMap::nof_cpu_regs; i++) {
    Register r = as_Register(i);
    if (r == G1 || r == G3 || r == G4 || r == G5) {
      __ ld_ptr(SP, (cpu_reg_save_offsets[i] * BytesPerWord) + STACK_BIAS, r);
    }
  }

  if (restore_fpu_registers) {
    for (int i = 0; i < FrameMap::nof_fpu_regs; i++) {
      FloatRegister r = as_FloatRegister(i);
      __ ldf(FloatRegisterImpl::S, SP, (fpu_reg_save_offsets[i] * BytesPerWord) + STACK_BIAS, r);
    }
  }
}
예제 #7
0
파일: kernel.c 프로젝트: zwizwa/staapl
void interpret_packet(void) {
    int size = rx(); // ignore.  protocol is self-terminating.
    (void)size;

    int command = rx();
    switch(command & 0x0F) {
    default:
    case 0: ack(); break;
    case 1: npush(); break;
    case 2: npop(); break;
    case 3: jsr(); break;
    case 4: lda(); break;
    case 5: ldf(); break;
    case 7: intr(); break;
    case 8: nafetch(); break;
    case 9: nffetch(); break;
    case 10: nastore(); break;
    case 11: nfstore(); break;
    }
    infof("\n");
}
예제 #8
0
NonTrivialNode* CompiledLoop::findDefInLoop(PReg* r) {
  assert(defsInLoop(r) == 1, "must have single definition in loop");
  LoopDefFinder ldf(this);
  r->forAllDefsDo(&ldf);
  return ldf.defNode;
}
// LP64 passes floating point arguments in F1, F3, F5, etc. instead of
// O0, O1, O2 etc..
// Doubles are passed in D0, D2, D4
// We store the signature of the first 16 arguments in the first argument
// slot because it will be overwritten prior to calling the native
// function, with the pointer to the JNIEnv.
// If LP64 there can be up to 16 floating point arguments in registers
// or 6 integer registers.
address AbstractInterpreterGenerator::generate_slow_signature_handler() {

  enum {
    non_float  = 0,
    float_sig  = 1,
    double_sig = 2,
    sig_mask   = 3
  };

  address entry = __ pc();
  Argument argv(0, true);

  // We are in the jni transition frame. Save the last_java_frame corresponding to the
  // outer interpreter frame
  //
  __ set_last_Java_frame(FP, noreg);
  // make sure the interpreter frame we've pushed has a valid return pc
  __ mov(O7, I7);
  __ mov(Lmethod, G3_scratch);
  __ mov(Llocals, G4_scratch);
  __ save_frame(0);
  __ mov(G2_thread, L7_thread_cache);
  __ add(argv.address_in_frame(), O3);
  __ mov(G2_thread, O0);
  __ mov(G3_scratch, O1);
  __ call(CAST_FROM_FN_PTR(address, InterpreterRuntime::slow_signature_handler), relocInfo::runtime_call_type);
  __ delayed()->mov(G4_scratch, O2);
  __ mov(L7_thread_cache, G2_thread);
  __ reset_last_Java_frame();


  // load the register arguments (the C code packed them as varargs)
  Address Sig = argv.address_in_frame();        // Argument 0 holds the signature
  __ ld_ptr( Sig, G3_scratch );                   // Get register argument signature word into G3_scratch
  __ mov( G3_scratch, G4_scratch);
  __ srl( G4_scratch, 2, G4_scratch);             // Skip Arg 0
  Label done;
  for (Argument ldarg = argv.successor(); ldarg.is_float_register(); ldarg = ldarg.successor()) {
    Label NonFloatArg;
    Label LoadFloatArg;
    Label LoadDoubleArg;
    Label NextArg;
    Address a = ldarg.address_in_frame();
    __ andcc(G4_scratch, sig_mask, G3_scratch);
    __ br(Assembler::zero, false, Assembler::pt, NonFloatArg);
    __ delayed()->nop();

    __ cmp(G3_scratch, float_sig );
    __ br(Assembler::equal, false, Assembler::pt, LoadFloatArg);
    __ delayed()->nop();

    __ cmp(G3_scratch, double_sig );
    __ br(Assembler::equal, false, Assembler::pt, LoadDoubleArg);
    __ delayed()->nop();

    __ bind(NonFloatArg);
    // There are only 6 integer register arguments!
    if ( ldarg.is_register() )
      __ ld_ptr(ldarg.address_in_frame(), ldarg.as_register());
    else {
    // Optimization, see if there are any more args and get out prior to checking
    // all 16 float registers.  My guess is that this is rare.
    // If is_register is false, then we are done the first six integer args.
      __ br_null_short(G4_scratch, Assembler::pt, done);
    }
    __ ba(NextArg);
    __ delayed()->srl( G4_scratch, 2, G4_scratch );

    __ bind(LoadFloatArg);
    __ ldf( FloatRegisterImpl::S, a, ldarg.as_float_register(), 4);
    __ ba(NextArg);
    __ delayed()->srl( G4_scratch, 2, G4_scratch );

    __ bind(LoadDoubleArg);
    __ ldf( FloatRegisterImpl::D, a, ldarg.as_double_register() );
    __ ba(NextArg);
    __ delayed()->srl( G4_scratch, 2, G4_scratch );

    __ bind(NextArg);

  }

  __ bind(done);
  __ ret();
  __ delayed()->
     restore(O0, 0, Lscratch);  // caller's Lscratch gets the result handler
  return entry;
}
예제 #10
0
void MgHtmlController::WriteSelectedFeatureAttributes(MgResourceService* resourceService,
                                                      MgSelection* selectionSet,
                                                      MgBatchPropertyCollection* attributes,
                                                      REFSTRING xmlOut)
{
    //Rather than doing a verbatim xml dump of MgBatchPropertyCollection, let's output something
    //that is more intuitive for client applications using this service operation to understand.

    //We could assume sorted layers in the MgBatchPropertyCollection, but play safe
    //and store our per-layer XML fragments in a bucket (keyed on layer name) and return 
    //the merged bucket result at the end
    std::map<STRING, STRING> bucket;

    MgAgfReaderWriter agfRw;
    MgWktReaderWriter wktRw;

    Ptr<MgReadOnlyLayerCollection> selLayers = selectionSet->GetLayers();
    if (NULL != selLayers.p)
    {
        // Our structure is as follows
        //
        // [0...n] <SelectedLayer> - A layer containing selected features
        //   [1] <LayerMetadata> - Describing properties, its display name and its property type. Due to how QueryFeatureProperties works, display names
        //                         are used for property names for each feature. This element provides a reverse lookup table to ascertain the FDO system 
        //                         property name for each attribute for client applications that require such information
        //     [0...n] <Feature> - Each selected feature in the layer
        //       [1] <Bounds> - The feature's bounding box [minx miny maxx maxy]
        //       [0...n] <Property> - Property value for current feature

        for (INT32 i = 0; i < selLayers->GetCount(); i++)
        {
            Ptr<MgLayerBase> selLayer = selLayers->GetItem(i);
            STRING layerName = selLayer->GetName();
            if (bucket.find(layerName) == bucket.end())
            {
                STRING xml = L"<SelectedLayer id=\"";
                xml.append(selLayer->GetObjectId());
                xml.append(L"\" name=\"");
                xml.append(selLayer->GetName());
                xml.append(L"\">\n");
                xml.append(L"<LayerMetadata>\n");
                Ptr<MgClassDefinition> clsDef = selLayer->GetClassDefinition();
                Ptr<MgPropertyDefinitionCollection> clsProps = clsDef->GetProperties();
                Ptr<MgResourceIdentifier> layerId = selLayer->GetLayerDefinition();
                //We need the property mappings of the source layer definition to compile our layer metadata
                std::auto_ptr<MdfModel::LayerDefinition> ldf(MgLayerBase::GetLayerDefinition(resourceService, layerId));
                if (ldf.get() != NULL)
                {
                    MdfModel::VectorLayerDefinition* vl = dynamic_cast<MdfModel::VectorLayerDefinition*>(ldf.get());
                    if(vl != NULL)
                    {
                        MdfModel::NameStringPairCollection* pmappings = vl->GetPropertyMappings();
                        for (int j=0; j<pmappings->GetCount(); j++)
                        {
                            STRING pTypeStr;
                            MdfModel::NameStringPair* m = pmappings->GetAt(j);
                            INT32 pidx = clsProps->IndexOf(m->GetName());
                            if (pidx >= 0)
                            {
                                Ptr<MgPropertyDefinition> propDef = clsProps->GetItem(pidx);
                                INT32 pdType = propDef->GetPropertyType();
                                INT32 pType = MgPropertyType::Null;
                                if (pdType == MgFeaturePropertyType::DataProperty)
                                {
                                    pType = ((MgDataPropertyDefinition*)propDef.p)->GetDataType();
                                }
                                else if (pdType == MgFeaturePropertyType::GeometricProperty)
                                {
                                    pType = MgPropertyType::Geometry;
                                }
                                MgUtil::Int32ToString(pType, pTypeStr);
                                xml.append(L"<Property>\n");
                                xml.append(L"<Name>");
                                xml.append(m->GetName());
                                xml.append(L"</Name>\n");
                                xml.append(L"<Type>");
                                xml.append(pTypeStr);
                                xml.append(L"</Type>\n");
                                xml.append(L"<DisplayName>");
                                xml.append(m->GetValue());
                                xml.append(L"</DisplayName>\n");
                                xml.append(L"</Property>\n");
                            }
                        }
                    }
                }
                xml += L"</LayerMetadata>\n";
                bucket[layerName] = xml;
            }
        }

        for (INT32 i = 0; i < attributes->GetCount(); i++)
        {
            Ptr<MgPropertyCollection> featProps = attributes->GetItem(i);
            INT32 lidx = featProps->IndexOf(L"_MgLayerName");
            INT32 fidx = featProps->IndexOf(L"_MgFeatureBoundingBox");

            //Must have both the _MgLayerName and _MgFeatureBoundingBox
            if (lidx < 0 || fidx < 0)
                continue;

            Ptr<MgStringProperty> layerNameProp = (MgStringProperty*)featProps->GetItem(lidx);
            Ptr<MgStringProperty> boundsProp = (MgStringProperty*)featProps->GetItem(fidx);

            //Locate the matching bucketed fragment to append to
            STRING layerName = layerNameProp->GetValue();
            if (bucket.find(layerName) != bucket.end())
            {
                //Good to go, write our feature to this bucketed fragment
                REFSTRING xml = bucket[layerName];
                xml.append(L"<Feature>\n");
                xml.append(L"<Bounds>");
                xml.append(boundsProp->GetValue());
                xml.append(L"</Bounds>\n");
                for (INT32 p = 0; p < featProps->GetCount(); p++)
                {
                    //Skip special properties
                    if (p == lidx || p == fidx)
                        continue;
                    Ptr<MgNullableProperty> prop = dynamic_cast<MgNullableProperty*>(featProps->GetItem(p));
                    if (NULL != prop.p)
                    {
                        xml.append(L"<Property>\n");
                        xml.append(L"<Name>");
                        xml.append(prop->GetName());
                        xml.append(L"</Name>\n");
                        //We'll follow MgProperty spec. Null is represented by omission of <Value>
                        if (!prop->IsNull())
                        {
                            INT32 ptype = prop->GetPropertyType();
                            switch(ptype)
                            {
                            //case MgPropertyType::Blob:
                            case MgPropertyType::Boolean:
                                {
                                    xml.append(L"<Value>");
                                    xml.append(((MgBooleanProperty*)prop.p)->GetValue() ? L"true" : L"false");
                                    xml.append(L"</Value>\n");
                                }
                                break;
                            case MgPropertyType::Byte:
                                {
                                    STRING sVal;
                                    MgUtil::Int32ToString((INT32)((MgByteProperty*)prop.p)->GetValue(), sVal);
                                    xml.append(L"<Value>");
                                    xml.append(sVal);
                                    xml.append(L"</Value>\n");
                                }
                                break;
                            //case MgPropertyType::Clob:
                            case MgPropertyType::DateTime:
                                {
                                    Ptr<MgDateTime> dt = ((MgDateTimeProperty*)prop.p)->GetValue();
                                    xml.append(L"<Value>");
                                    xml.append(dt->ToXmlString());
                                    xml.append(L"</Value>\n");
                                }
                                break;
                            case MgPropertyType::Decimal:
                            case MgPropertyType::Double:
                                {
                                    STRING sVal;
                                    MgUtil::DoubleToString(((MgDoubleProperty*)prop.p)->GetValue(), sVal);
                                    xml.append(L"<Value>");
                                    xml.append(sVal);
                                    xml.append(L"</Value>\n");
                                }
                                break;
                            case MgPropertyType::Geometry:
                                {
                                    try 
                                    {
                                        Ptr<MgByteReader> agf = ((MgGeometryProperty*)prop.p)->GetValue();
                                        Ptr<MgGeometry> geom = agfRw.Read(agf);
                                        STRING wkt = wktRw.Write(geom);
                                        xml.append(L"<Value>");
                                        xml.append(wkt);
                                        xml.append(L"</Value>\n");
                                    }
                                    catch (MgException* ex) //Bad geom maybe
                                    {
                                        SAFE_RELEASE(ex);
                                    }
                                }
                                break;
                            case MgPropertyType::Int16:
                                {
                                    STRING sVal;
                                    MgUtil::Int32ToString((INT32)((MgInt16Property*)prop.p)->GetValue(), sVal);
                                    xml.append(L"<Value>");
                                    xml.append(sVal);
                                    xml.append(L"</Value>\n");
                                }
                                break;
                            case MgPropertyType::Int32:
                                {
                                    STRING sVal;
                                    MgUtil::Int32ToString(((MgInt32Property*)prop.p)->GetValue(), sVal);
                                    xml.append(L"<Value>");
                                    xml.append(sVal);
                                    xml.append(L"</Value>\n");
                                }
                                break;
                            case MgPropertyType::Int64:
                                {
                                    STRING sVal;
                                    MgUtil::Int64ToString(((MgInt64Property*)prop.p)->GetValue(), sVal);
                                    xml.append(L"<Value>");
                                    xml.append(sVal);
                                    xml.append(L"</Value>\n");
                                }
                                break;
                            case MgPropertyType::Single:
                                {
                                    STRING sVal;
                                    MgUtil::SingleToString(((MgSingleProperty*)prop.p)->GetValue(), sVal);
                                    xml.append(L"<Value>");
                                    xml.append(sVal);
                                    xml.append(L"</Value>\n");
                                }
                                break;
                            case MgPropertyType::String:
                                {
                                    xml.append(L"<Value>");
                                    xml.append(MgUtil::ReplaceEscapeCharInXml(((MgStringProperty*)prop.p)->GetValue()));
                                    xml.append(L"</Value>\n");
                                }
                                break;
                            }
                        }
                        xml.append(L"</Property>\n");
                    }
                }
                xml.append(L"</Feature>\n");
            }
        }
    
        //Now merge the bucketed fragments
        for (std::map<STRING, STRING>::iterator it = bucket.begin(); it != bucket.end(); it++)
        {
            //Close off the <SelectedLayer> elements
            STRING xml = it->second;
            xml.append(L"</SelectedLayer>");
            //Good to append to the final result
            xmlOut.append(xml);
        }
    }
}
inline void MacroAssembler::ldf(FloatRegisterImpl::Width w, Register s1, RegisterOrConstant s2, FloatRegister d) {
  if (s2.is_register())  ldf(w, s1, s2.as_register(), d);
  else                   ldf(w, s1, s2.as_constant(), d);
}
void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {
  Argument  jni_arg(jni_offset(), false);
  FloatRegister  Rtmp = F0;
  __ ldf(FloatRegisterImpl::S, Llocals, -offset() * wordSize, Rtmp);
  __ store_float_argument(Rtmp, jni_arg);
}