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/_dValueArray_prims.cpp.incl"
00026
00027 TRACE_FUNC(TraceDoubleValueArrayPrims, "doubleValueArray")
00028
00029 int doubleValueArrayPrimitives::number_of_calls;
00030
00031 #define ASSERT_RECEIVER assert(receiver->is_doubleValueArray(), "receiver must be double value array")
00032
00033 PRIM_DECL_2(doubleValueArrayPrimitives::allocateSize, oop receiver, oop argument) {
00034 PROLOGUE_2("allocateSize", receiver, argument)
00035 assert(receiver->is_klass() && klassOop(receiver)->klass_part()->oop_is_doubleValueArray(),
00036 "receiver must double byte array class");
00037 if (!argument->is_smi())
00038 markSymbol(vmSymbols::first_argument_has_wrong_type());
00039
00040 if (smiOop(argument)->value() < 0)
00041 return markSymbol(vmSymbols::negative_size());
00042
00043 int length = smiOop(argument)->value();
00044
00045 klassOop k = klassOop(receiver);
00046 int ni_size = k->klass_part()->non_indexable_size();
00047 int obj_size = ni_size + 1 + roundTo(length * sizeof(double), oopSize) / oopSize;
00048
00049 doubleValueArrayOop obj = as_doubleValueArrayOop(Universe::allocate(obj_size, (memOop*)&k));
00050
00051 memOop(obj)->initialize_header(true, k);
00052
00053 memOop(obj)->initialize_body(memOopDesc::header_size(), ni_size);
00054 obj->set_length(length);
00055 for (int index = 1; index <= length; index++) {
00056 obj->double_at_put(index, 0.0);
00057 }
00058 return obj;
00059 }
00060
00061 PRIM_DECL_1(doubleValueArrayPrimitives::size, oop receiver) {
00062 PROLOGUE_1("size", receiver);
00063 ASSERT_RECEIVER;
00064
00065
00066 return as_smiOop(doubleValueArrayOop(receiver)->length());
00067 }
00068
00069 PRIM_DECL_2(doubleValueArrayPrimitives::at, oop receiver, oop index) {
00070 PROLOGUE_2("at", receiver, index);
00071 ASSERT_RECEIVER;
00072
00073
00074 if (!index->is_smi())
00075 return markSymbol(vmSymbols::first_argument_has_wrong_type());
00076
00077
00078 if (!doubleValueArrayOop(receiver)->is_within_bounds(smiOop(index)->value()))
00079 return markSymbol(vmSymbols::out_of_bounds());
00080
00081 return oopFactory::new_double(doubleValueArrayOop(receiver)->double_at(smiOop(index)->value()));
00082 }
00083
00084 PRIM_DECL_3(doubleValueArrayPrimitives::atPut, oop receiver, oop index, oop value) {
00085 PROLOGUE_3("atPut", receiver, index, value);
00086 ASSERT_RECEIVER;
00087
00088
00089 if (!index->is_smi())
00090 return markSymbol(vmSymbols::first_argument_has_wrong_type());
00091
00092
00093 if (!value->is_double())
00094 return markSymbol(vmSymbols::second_argument_has_wrong_type());
00095
00096
00097 if (!doubleValueArrayOop(receiver)->is_within_bounds(smiOop(index)->value()))
00098 return markSymbol(vmSymbols::out_of_bounds());
00099
00100
00101 doubleValueArrayOop(receiver)->double_at_put(smiOop(index)->value(), doubleOop(value)->value());
00102 return receiver;
00103 }
00104