Пример #1
0
void run( const int N, const int M, const int L, const int hyper_threads, const int vector_lanes,
                  const int nx, const int ny, const int nz, const int ichunk,
                  const int nang, const int noct, const int ng, const int nmom, const int cmom,
                  const vector<diag_c>& diag )
{
  
	typedef typename Kokkos::DefaultExecutionSpace device_t;
	typedef TeamPolicy<device_t> team_policy_t;
	typedef View<double*, device_t> view_1d_t;
	typedef View<double**, Kokkos::LayoutLeft, device_t> view_2d_t;
	typedef View<double***, Kokkos::LayoutLeft, device_t> view_3d_t;
	typedef View<double****, Kokkos::LayoutLeft, device_t> view_4d_t;
	typedef View<double*****, Kokkos::LayoutLeft, device_t> view_5d_t;
	typedef View<double******, Kokkos::LayoutLeft, device_t> view_6d_t;
	typedef View<double*******, Kokkos::LayoutLeft, device_t> view_7d_t;


	int id = 1;
	int ich = 1;
	int jlo = 0;
	int jhi = ny-1;
	int jst = 1;
	int jd = 2;
	int klo = 0;
	int khi = nz-1;
	int kst = 1;
	int kd = 2;
	double hi = c1;
	
	Kokkos::initialize();
	Kokkos::DefaultExecutionSpace::print_configuration(cout);
	
	view_4d_t psii( "psii", nang, ny, nz, ng );
	view_4d_t psij( "psij", nang, ichunk, nz, ng );
	view_4d_t psik( "psik", nang, ichunk, ny, ng );
	view_4d_t jb_in( "jb_in", nang, ichunk, ny, ng ); // jb_in(nang,ichunk,nz,ng)
	view_4d_t kb_in( "kb_in", nang, ichunk, ny, ng ); // kb_in(nang,ichunk,nz,ng)
	view_6d_t qim( "qim", nang, nx, ny, nz, noct, ng ); // qim(nang,nx,ny,nz,noct,ng)
  view_5d_t qtot( "qtot", cmom, nx, ny, nx, ng ); // qtot(cmom,nx,ny,nz,ng)
	view_2d_t ec( "ec", nang, cmom ); // ec(nang,cmom)
	view_1d_t mu( "mu", nang ); // mu(nang)
	view_1d_t w( "w", nang ); // w(nang)
	view_1d_t wmu( "wmu", nang ); // wmu(nang)
	view_1d_t weta( "weta", nang ); // weta(nang)
	view_1d_t wxi( "wxi", nang ); // wxi(nang)
	view_1d_t hj( "hj", nang ); // hj(nang)
	view_1d_t hk( "hk", nang ); // hk(nang)
	view_1d_t vdelt( "vdelt", ng ); // vdelt(ng)
	view_6d_t ptr_in( "ptr_in", nang, nx, ny, nz, noct, ng ); // ptr_in(nang,nx,ny,nz,noct,ng)
	view_6d_t ptr_out( "ptr_out", nang, nx, ny, nz, noct, ng ); // ptr_out(nang,nx,ny,nz,noct,ng)
	view_4d_t flux( "flux", nx, ny, nz, ng ); // flux(nx,ny,nz,ng)
	view_5d_t fluxm( "fluxm", cmom-1, nx, ny, nz, ng ); //fluxm(cmom-1,nx,ny,nz,ng)
	view_2d_t psi( "psi", nang, M );
	view_2d_t pc( "pc", nang, M );
	view_4d_t jb_out( "jb_out", nang, ichunk, nz, ng );
	view_4d_t kb_out( "kb_out", nang, ichunk, ny, ng );
	view_4d_t flkx( "flkx", nx+1, ny, nz, ng );
	view_4d_t flky( "flky", nx, ny+1, nz, ng );
	view_4d_t flkz( "flkz", nx, ny, nz+1, ng );
  view_3d_t hv( "hv", nang, 4, M ); // hv(nang,4,M)
  view_3d_t fxhv( "fxhv", nang, 4, M ); // fxhv(nang,4,M)
  view_5d_t dinv( "dinv", nang, nx, ny, nz, ng ); // dinv(nang,nx,ny,nz,ng)
  view_2d_t den( "den", nang, M ); // den(nang,M)
  view_4d_t t_xs( "t_xs", nx, ny, nz, ng ); // t_xs(nx,ny,nz,ng)
   	  
  const team_policy_t policy( N, hyper_threads, vector_lanes );
  
  for (int ii = 0; ii < n_test_iter; ii++) {
    Kokkos::Impl::Timer timer;
    
    for (int oct = 0; oct < noct; oct++) {
      parallel_for( policy, dim3_sweep2<  team_policy_t,
                                          view_1d_t, view_2d_t, view_3d_t, view_4d_t,
                                          view_5d_t, view_6d_t, view_7d_t >
                                        ( M, L,
                                          ng, cmom, noct,
                                          nx, ny, nz, ichunk,
                                          diag,
                                          id, ich, oct,
                                          jlo, jhi, jst, jd,
                                          klo, khi, kst, kd,
                                          psii, psij, psik,
                                          jb_in, kb_in,
                                          qim, qtot, ec,
                                          mu, w,
                                          wmu, weta, wxi,
                                          hi, hj, hk,
                                          vdelt, ptr_in, ptr_out,
                                          flux, fluxm, psi, pc,
                                          jb_out, kb_out,
                                          flkx, flky, flkz,
                                          hv, fxhv, dinv,
                                          den, t_xs ) );
    }// end noct
    
    std::cout << " ii " << ii << " elapsed time " << timer.seconds() << std::endl;
  } // end n_test_iter	
	
	Kokkos::finalize();
}
void
DropDownListClientWKC::hide(WebCore::PopupMenuClient *client)
{
    PopupMenuClientPrivate pc(client);
    m_appClient->hide(&pc.wkc());
}
Пример #3
0
int main(int argc, char **args) 
{
  // Test variable.
  int success_test = 1;

  if (argc < 2) error("Not enough parameters.");

  // Load the mesh.
	Mesh mesh;
  H3DReader mloader;
  if (!mloader.load(args[1], &mesh)) error("Loading mesh file '%s'.", args[1]);

	// Initialize the space.
	int mx = 2;
	Ord3 order(mx, mx, mx);
	H1Space space(&mesh, bc_types, NULL, order);
#if defined LIN_DIRICHLET || defined NLN_DIRICHLET
	space.set_essential_bc_values(essential_bc_values);
#endif
	// Initialize the weak formulation.
	WeakForm wf;
	wf.add_vector_form(form_0<double, scalar>, form_0<Ord, Ord>);
#if defined LIN_NEUMANN || defined LIN_NEWTON
	wf.add_vector_form_surf(form_0_surf<double, scalar>, form_0_surf<Ord, Ord>);
#endif
#if defined LIN_DIRICHLET || defined NLN_DIRICHLET
	// preconditioner
	wf.add_matrix_form(precond_0_0<double, scalar>, precond_0_0<Ord, Ord>, HERMES_SYM);
#endif

	// Initialize the FE problem.
	DiscreteProblem fep(&wf, &space);

#if defined LIN_DIRICHLET || defined NLN_DIRICHLET
	// use ML preconditioner to speed-up things
	MlPrecond pc("sa");
	pc.set_param("max levels", 6);
	pc.set_param("increasing or decreasing", "decreasing");
	pc.set_param("aggregation: type", "MIS");
	pc.set_param("coarse: type", "Amesos-KLU");
#endif

	NoxSolver solver(&fep);
#if defined LIN_DIRICHLET || defined NLN_DIRICHLET
//	solver.set_precond(&pc);
#endif

	info("Solving.");
	Solution sln(&mesh);
	if(solver.solve()) Solution::vector_to_solution(solver.get_solution(), &space, &sln);
  else error ("Matrix solver failed.\n");
	

		Solution ex_sln(&mesh);
		ex_sln.set_exact(exact_solution);

		// Calculate exact error.
  info("Calculating exact error.");
  Adapt *adaptivity = new Adapt(&space, HERMES_H1_NORM);
  bool solutions_for_adapt = false;
  double err_exact = adaptivity->calc_err_exact(&sln, &ex_sln, solutions_for_adapt, HERMES_TOTAL_ERROR_ABS);

  if (err_exact > EPS)
		// Calculated solution is not precise enough.
		success_test = 0;

  if (success_test) {
    info("Success!");
    return ERR_SUCCESS;
  }
  else {
    info("Failure!");
    return ERR_FAILURE;
  }
}
Пример #4
0
std::string countPaths(S& spec, bool fast = false) {
    PathCounter<S> pc(spec);
    return fast ? pc.countFast() : pc.count();
}
Пример #5
0
bool frame::is_interpreted_frame() const  {
  return Interpreter::contains(pc());
}
Пример #6
0
    Py::Object approxSurface(const Py::Tuple& args, const Py::Dict& kwds)
    {
        PyObject *o;
        // spline parameters
        int uDegree = 3;
        int vDegree = 3;
        int uPoles = 6;
        int vPoles = 6;
        // smoothing
        PyObject* smooth = Py_True;
        double weight = 0.1;
        double grad = 1.0;  //0.5
        double bend = 0.0; //0.2
        // other parameters
        int iteration = 5;
        PyObject* correction = Py_True;
        double factor = 1.0;

        static char* kwds_approx[] = {"Points", "UDegree", "VDegree", "NbUPoles", "NbVPoles",
                                      "Smooth", "Weight", "Grad", "Bend",
                                      "Iterations", "Correction", "PatchFactor", NULL};
        if (!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "O|iiiiO!dddiO!d",kwds_approx,
                                        &o,&uDegree,&vDegree,&uPoles,&vPoles,
                                        &PyBool_Type,&smooth,&weight,&grad,&bend,
                                        &iteration,&PyBool_Type,&correction,&factor))
            throw Py::Exception();

        double curvdiv = 1.0 - (grad + bend);
        int uOrder = uDegree + 1;
        int vOrder = vDegree + 1;

        // error checking
        if (grad < 0.0 || grad > 1.0) {
            throw Py::ValueError("Value of Grad out of range [0,1]");
        }
        if (bend < 0.0 || bend > 1.0) {
            throw Py::ValueError("Value of Bend out of range [0,1]");
        }
        if (curvdiv < 0.0 || curvdiv > 1.0) {
            throw Py::ValueError("Sum of Grad and Bend out of range [0,1]");
        }
        if (uDegree < 1 || uOrder > uPoles) {
            throw Py::ValueError("Value of uDegree out of range [1,NbUPoles-1]");
        }
        if (vDegree < 1 || vOrder > vPoles) {
            throw Py::ValueError("Value of vDegree out of range [1,NbVPoles-1]");
        }

        try {
            Py::Sequence l(o);
            TColgp_Array1OfPnt clPoints(0, l.size()-1);
            if (clPoints.Length() < uPoles * vPoles) {
                throw Py::ValueError("Too less data points for the specified number of poles");
            }

            int index=0;
            for (Py::Sequence::iterator it = l.begin(); it != l.end(); ++it) {
                Py::Tuple t(*it);
                clPoints(index++) = gp_Pnt(
                    (double)Py::Float(t.getItem(0)),
                    (double)Py::Float(t.getItem(1)),
                    (double)Py::Float(t.getItem(2)));
            }

            Reen::BSplineParameterCorrection pc(uOrder,vOrder,uPoles,vPoles);
            Handle_Geom_BSplineSurface hSurf;

            pc.EnableSmoothing(PyObject_IsTrue(smooth) ? true : false, weight, grad, bend, curvdiv);
            hSurf = pc.CreateSurface(clPoints, iteration, PyObject_IsTrue(correction) ? true : false, factor);
            if (!hSurf.IsNull()) {
                return Py::asObject(new Part::BSplineSurfacePy(new Part::GeomBSplineSurface(hSurf)));
            }

            throw Py::RuntimeError("Computation of B-Spline surface failed");
        }
        catch (Standard_Failure &e) {
            std::string str;
            Standard_CString msg = e.GetMessageString();
            str += typeid(e).name();
            str += " ";
            if (msg) {str += msg;}
            else     {str += "No OCCT Exception Message";}
            throw Py::RuntimeError(str);
        }
        catch (const Base::Exception &e) {
            throw Py::RuntimeError(e.what());
        }
        catch (...) {
            throw Py::RuntimeError("Unknown C++ exception");
        }
    }
Пример #7
0
void MacroAssembler::store_oop(jobject obj) {
  code_section()->relocate(pc(), oop_Relocation::spec_for_immediate());
  emit_address((address) obj);
}
address InterpreterGenerator::generate_math_entry(AbstractInterpreter::MethodKind kind) {

  // rbx,: Method*
  // rcx: scratrch
  // r13: sender sp

  if (!InlineIntrinsics) return NULL; // Generate a vanilla entry

  address entry_point = __ pc();

  // These don't need a safepoint check because they aren't virtually
  // callable. We won't enter these intrinsics from compiled code.
  // If in the future we added an intrinsic which was virtually callable
  // we'd have to worry about how to safepoint so that this code is used.

  // mathematical functions inlined by compiler
  // (interpreter must provide identical implementation
  // in order to avoid monotonicity bugs when switching
  // from interpreter to compiler in the middle of some
  // computation)
  //
  // stack: [ ret adr ] <-- rsp
  //        [ lo(arg) ]
  //        [ hi(arg) ]
  //

  // Note: For JDK 1.2 StrictMath doesn't exist and Math.sin/cos/sqrt are
  //       native methods. Interpreter::method_kind(...) does a check for
  //       native methods first before checking for intrinsic methods and
  //       thus will never select this entry point. Make sure it is not
  //       called accidentally since the SharedRuntime entry points will
  //       not work for JDK 1.2.
  //
  // We no longer need to check for JDK 1.2 since it's EOL'ed.
  // The following check existed in pre 1.6 implementation,
  //    if (Universe::is_jdk12x_version()) {
  //      __ should_not_reach_here();
  //    }
  // Universe::is_jdk12x_version() always returns false since
  // the JDK version is not yet determined when this method is called.
  // This method is called during interpreter_init() whereas
  // JDK version is only determined when universe2_init() is called.

  // Note: For JDK 1.3 StrictMath exists and Math.sin/cos/sqrt are
  //       java methods.  Interpreter::method_kind(...) will select
  //       this entry point for the corresponding methods in JDK 1.3.
  // get argument

  if (kind == Interpreter::java_lang_math_sqrt) {
    __ sqrtsd(xmm0, Address(rsp, wordSize));
  } else {
    __ fld_d(Address(rsp, wordSize));
    switch (kind) {
      case Interpreter::java_lang_math_sin :
          __ trigfunc('s');
          break;
      case Interpreter::java_lang_math_cos :
          __ trigfunc('c');
          break;
      case Interpreter::java_lang_math_tan :
          __ trigfunc('t');
          break;
      case Interpreter::java_lang_math_abs:
          __ fabs();
          break;
      case Interpreter::java_lang_math_log:
          __ flog();
          break;
      case Interpreter::java_lang_math_log10:
          __ flog10();
          break;
      case Interpreter::java_lang_math_pow:
          __ fld_d(Address(rsp, 3*wordSize)); // second argument (one
                                              // empty stack slot)
          __ pow_with_fallback(0);
          break;
      case Interpreter::java_lang_math_exp:
          __ exp_with_fallback(0);
           break;
      default                              :
          ShouldNotReachHere();
    }

    // return double result in xmm0 for interpreter and compilers.
    __ subptr(rsp, 2*wordSize);
    // Round to 64bit precision
    __ fstp_d(Address(rsp, 0));
    __ movdbl(xmm0, Address(rsp, 0));
    __ addptr(rsp, 2*wordSize);
  }


  __ pop(rax);
  __ mov(rsp, r13);
  __ jmp(rax);

  return entry_point;
}
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
  address entry = __ pc();

  // rbx: method
  // r14: pointer to locals
  // c_rarg3: first stack arg - wordSize
  __ mov(c_rarg3, rsp);
  // adjust rsp
  __ subptr(rsp, 4 * wordSize);
  __ call_VM(noreg,
             CAST_FROM_FN_PTR(address,
                              InterpreterRuntime::slow_signature_handler),
             rbx, r14, c_rarg3);

  // rax: result handler

  // Stack layout:
  // rsp: 3 integer or float args (if static first is unused)
  //      1 float/double identifiers
  //        return address
  //        stack args
  //        garbage
  //        expression stack bottom
  //        bcp (NULL)
  //        ...

  // Do FP first so we can use c_rarg3 as temp
  __ movl(c_rarg3, Address(rsp, 3 * wordSize)); // float/double identifiers

  for ( int i= 0; i < Argument::n_int_register_parameters_c-1; i++ ) {
    XMMRegister floatreg = as_XMMRegister(i+1);
    Label isfloatordouble, isdouble, next;

    __ testl(c_rarg3, 1 << (i*2));      // Float or Double?
    __ jcc(Assembler::notZero, isfloatordouble);

    // Do Int register here
    switch ( i ) {
      case 0:
        __ movl(rscratch1, Address(rbx, Method::access_flags_offset()));
        __ testl(rscratch1, JVM_ACC_STATIC);
        __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));
        break;
      case 1:
        __ movptr(c_rarg2, Address(rsp, wordSize));
        break;
      case 2:
        __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
        break;
      default:
        break;
    }

    __ jmp (next);

    __ bind(isfloatordouble);
    __ testl(c_rarg3, 1 << ((i*2)+1));     // Double?
    __ jcc(Assembler::notZero, isdouble);

// Do Float Here
    __ movflt(floatreg, Address(rsp, i * wordSize));
    __ jmp(next);

// Do Double here
    __ bind(isdouble);
    __ movdbl(floatreg, Address(rsp, i * wordSize));

    __ bind(next);
  }


  // restore rsp
  __ addptr(rsp, 4 * wordSize);

  __ ret(0);

  return entry;
}
Пример #10
0
void Camera::zBufferLookAt( int pixel_x, int pixel_y ) {

   int W = _viewport_x2 - _viewport_x1 + 1;
   int H = _viewport_y2 - _viewport_y1 + 1;

   GLfloat * zbuffer = new GLfloat[ W * H ];

   // FIXME: we want to fetch the z-buffer of the most
   // recently rendered image.  Unfortunately, this code
   // probably grabs the back z-buffer, rather than the
   // front z-buffer, which (if I'm not mistaken) is what we want.
   // FIXME: instead of grabbing the whole buffer, we should just
   // grab a small region around the pixel of interest.
   // Grabbing the whole buffer is very slow on
   // some Iris machines (e.g. Indigo2).
   glReadPixels(
      _viewport_x1,
      _window_height_in_pixels - 1 - _viewport_y2,
      W, H,
      GL_DEPTH_COMPONENT, GL_FLOAT, zbuffer
   );

   // // Print contents of z-buffer (for debugging only).
   // for ( int b = H-1; b >= 0; --b ) {
   //    for ( int a = 0; a < W; ++a ) {
   //       printf("%c",zbuffer[ b*W + a ]==1?'.':'X');
   //    }
   //    puts("");
   // }

   // Keep in mind that zbuffer[0] corresponds to the lower-left
   // pixel of the viewport, *not* the upper-left pixel.

   // Transform the pixel passed in so that it is
   // in the z-buffer's coordinate system.
   pixel_x -= _viewport_x1;
   pixel_y = H - 1 - (pixel_y - _viewport_y1);

   // Assume, as is typically the case, that the z-buffer was
   // cleared with a value of 1.0f (the maximum z value).
   // Also assume that any pixels containing a value of 1.0f
   // have this value because no rendered geometry covered them.
   // Now, search outward from the pixel passed in, in larger
   // and larger rectangles, for a pixel with a z value
   // less than 1.0f.

   ASSERT( 0 <= pixel_x && pixel_x < W && 0 <= pixel_y && pixel_y < H );

   // the search rectangle
   int x1 = pixel_x, y1 = pixel_y;
   int x2 = x1, y2 = y1;

   int x,y,x0=W/2,y0=H/2;
   int min, max;
   float z = 1;
   while ( z == 1 ) {
      // top edge of rectangle
      if ( y1 >= 0 ) {
         y = y1;
         min = x1 < 0 ? 0 : x1;
         max = x2 >= W ? W-1 : x2;
         for ( x = min; x <= max; ++x )
            if ( zbuffer[ y*W + x ] < z ) {
               z = zbuffer[ y*W + x ];
               x0 = x;
               y0 = y;
            }
      }
      // bottom edge of rectangle
      if ( y2 < H ) {
         y = y2;
         min = x1 < 0 ? 0 : x1;
         max = x2 >= W ? W-1 : x2;
         for ( x = min; x <= max; ++x )
            if ( zbuffer[ y*W + x ] < z ) {
               z = zbuffer[ y*W + x ];
               x0 = x;
               y0 = y;
            }
      }
      // left edge of rectangle
      if ( x1 >= 0 ) {
         x = x1;
         min = y1 < 0 ? 0 : y1;
         max = y2 >= H ? H-1 : y2;
         for ( y = min; y <= max; ++y )
            if ( zbuffer[ y*W + x ] < z ) {
               z = zbuffer[ y*W + x ];
               x0 = x;
               y0 = y;
            }
      }
      // right edge of rectangle
      if ( x2 < W ) {
         x = x2;
         min = y1 < 0 ? 0 : y1;
         max = y2 >= H ? H-1 : y2;
         for ( y = min; y <= max; ++y )
            if ( zbuffer[ y*W + x ] < z ) {
               z = zbuffer[ y*W + x ];
               x0 = x;
               y0 = y;
            }
      }

      // grow the rectangle
      --x1;  --y1;
      ++x2;  ++y2;

      // is there nothing left to search ?
      if ( y1 < 0 && y2 >= H && x1 < 0 && x2 >= W )
         break;
   }

   if ( z < 1 ) {
      // compute point in clipping space
#ifdef OPENGL_CENTRE_BASED
      Point3 pc( 2*x0/(float)(W-1)-1, 2*y0/(float)(H-1)-1, 2*z-1 );
#else
      // The +0.5f here is to convert from centre-based coordinates
      // to edge-based coordinates.
      Point3 pc( 2*(x0+0.5f)/(float)W-1, 2*(y0+0.5f)/(float)H-1, 2*z-1 );
#endif

      // compute inverse view transform
      Matrix M;
      M.setToLookAt( _position, _target, _up, true );

      // compute inverse perspective transform
      Matrix M2;
      M2.setToFrustum(
         - 0.5 * _viewport_width,  0.5 * _viewport_width,    // left, right
         - 0.5 * _viewport_height, 0.5 * _viewport_height,   // bottom, top
         _near_plane, _far_plane,
         true
      );

      // compute inverse of light transform
      M = M * M2;

      // compute point in world space
      Point3 t0 = M * pc;
      Point3 t( t0.x()/t0.w(), t0.y()/t0.w(), t0.z()/t0.w() );

      lookAt( t );
   }

   delete [] zbuffer;
   zbuffer = 0;
}
address AbstractInterpreterGenerator::generate_slow_signature_handler() {
  address entry = __ pc();

  // rbx: method
  // r14: pointer to locals
  // c_rarg3: first stack arg - wordSize
  __ mov(c_rarg3, rsp);
  // adjust rsp
  __ subptr(rsp, 14 * wordSize);
  __ call_VM(noreg,
             CAST_FROM_FN_PTR(address,
                              InterpreterRuntime::slow_signature_handler),
             rbx, r14, c_rarg3);

  // rax: result handler

  // Stack layout:
  // rsp: 5 integer args (if static first is unused)
  //      1 float/double identifiers
  //      8 double args
  //        return address
  //        stack args
  //        garbage
  //        expression stack bottom
  //        bcp (NULL)
  //        ...

  // Do FP first so we can use c_rarg3 as temp
  __ movl(c_rarg3, Address(rsp, 5 * wordSize)); // float/double identifiers

  for (int i = 0; i < Argument::n_float_register_parameters_c; i++) {
    const XMMRegister r = as_XMMRegister(i);

    Label d, done;

    __ testl(c_rarg3, 1 << i);
    __ jcc(Assembler::notZero, d);
    __ movflt(r, Address(rsp, (6 + i) * wordSize));
    __ jmp(done);
    __ bind(d);
    __ movdbl(r, Address(rsp, (6 + i) * wordSize));
    __ bind(done);
  }

  // Now handle integrals.  Only do c_rarg1 if not static.
  __ movl(c_rarg3, Address(rbx, Method::access_flags_offset()));
  __ testl(c_rarg3, JVM_ACC_STATIC);
  __ cmovptr(Assembler::zero, c_rarg1, Address(rsp, 0));

  __ movptr(c_rarg2, Address(rsp, wordSize));
  __ movptr(c_rarg3, Address(rsp, 2 * wordSize));
  __ movptr(c_rarg4, Address(rsp, 3 * wordSize));
  __ movptr(c_rarg5, Address(rsp, 4 * wordSize));

  // restore rsp
  __ addptr(rsp, 14 * wordSize);

  __ ret(0);

  return entry;
}
inline bool frame::equal(frame other) const {
  return sp() == other.sp()
      && fp() == other.fp()
      && pc() == other.pc();
}
Пример #13
0
boost::shared_ptr<PointCloud> CloudList::addCloud(const char* filename) {
    boost::shared_ptr<PointCloud> pc(new PointCloud());
    pc->load_ptx(filename);
    return addCloud(pc);
}
Пример #14
0
boost::shared_ptr<PointCloud> CloudList::addCloud() {
    boost::shared_ptr<PointCloud> pc(new PointCloud());
    return addCloud(pc);
}
TEST_F(LoadPlanningModelsPr2, PoseConstraintSamplerManager)
{
  robot_state::RobotState ks(kmodel);
  ks.setToDefaultValues();
  ks.update();
  robot_state::RobotState ks_const(kmodel);
  ks_const.setToDefaultValues();
  ks_const.update();

  kinematic_constraints::PositionConstraint pc(kmodel);

  moveit_msgs::PositionConstraint pcm;
  pcm.link_name = "l_wrist_roll_link";
  pcm.target_point_offset.x = 0;
  pcm.target_point_offset.y = 0;
  pcm.target_point_offset.z = 0;
  pcm.constraint_region.primitives.resize(1);
  pcm.constraint_region.primitives[0].type = shape_msgs::SolidPrimitive::SPHERE;
  pcm.constraint_region.primitives[0].dimensions.resize(1);
  pcm.constraint_region.primitives[0].dimensions[0] = 0.001;

  pcm.header.frame_id = kmodel->getModelFrame();

  pcm.constraint_region.primitive_poses.resize(1);
  pcm.constraint_region.primitive_poses[0].position.x = 0.55;
  pcm.constraint_region.primitive_poses[0].position.y = 0.2;
  pcm.constraint_region.primitive_poses[0].position.z = 1.25;
  pcm.constraint_region.primitive_poses[0].orientation.x = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.y = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.z = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.w = 1.0;
  pcm.weight = 1.0;

  moveit_msgs::OrientationConstraint ocm;

  ocm.link_name = "l_wrist_roll_link";
  ocm.header.frame_id = kmodel->getModelFrame();
  ocm.orientation.x = 0.0;
  ocm.orientation.y = 0.0;
  ocm.orientation.z = 0.0;
  ocm.orientation.w = 1.0;
  ocm.absolute_x_axis_tolerance = 0.2;
  ocm.absolute_y_axis_tolerance = 0.1;
  ocm.absolute_z_axis_tolerance = 0.4;
  ocm.weight = 1.0;

  // test the automatic construction of constraint sampler
  moveit_msgs::Constraints c;
  c.position_constraints.push_back(pcm);
  c.orientation_constraints.push_back(ocm);

  constraint_samplers::ConstraintSamplerPtr s = constraint_samplers::ConstraintSamplerManager::selectDefaultSampler(ps, "left_arm", c);
  EXPECT_TRUE(s.get() != NULL);
  constraint_samplers::IKConstraintSampler* iks = dynamic_cast<constraint_samplers::IKConstraintSampler*>(s.get());
  ASSERT_TRUE(iks);
  ASSERT_TRUE(iks->getPositionConstraint());
  ASSERT_TRUE(iks->getOrientationConstraint());

  static const int NT = 100;
  int succ = 0;
  for (int t = 0 ; t < NT ; ++t)
  {
    EXPECT_TRUE(s->sample(ks, ks_const, 100));
    EXPECT_TRUE(iks->getPositionConstraint()->decide(ks).satisfied);
    EXPECT_TRUE(iks->getOrientationConstraint()->decide(ks).satisfied);
    if (s->sample(ks, ks_const, 1))
      succ++;
  }
  ROS_INFO("Success rate for IK Constraint Sampler with position & orientation constraints for one arm: %lf", (double)succ / (double)NT);

  //add additional ocm with smaller volume
  ocm.absolute_x_axis_tolerance = 0.1;

  c.orientation_constraints.push_back(ocm);

  s = constraint_samplers::ConstraintSamplerManager::selectDefaultSampler(ps, "left_arm", c);
  EXPECT_TRUE(s.get() != NULL);

  iks = dynamic_cast<constraint_samplers::IKConstraintSampler*>(s.get());
  ASSERT_TRUE(iks);
  ASSERT_TRUE(iks->getOrientationConstraint());
  EXPECT_NEAR(iks->getOrientationConstraint()->getXAxisTolerance(),.1, .0001);
}
Пример #16
0
int main(int argc, const char *argv[]) {
	// Pick up configuration parameters
	boost::program_options::variables_map vm;

	bool bTest, bBuild, bPackage;
	bTest = bBuild = bPackage = false;
	unsigned int iLogRotationSize;
	std::string sWorkingDir;
	std::string sStageDir;
	std::string sInstallPrefix;
	std::string sPackageName;
	std::string sPackageControlFile;
	std::string sArchitecture;
	std::string sSection;
	std::string sCfgfile;
	std::string sRosVersion;
	std::string sPriority;
	std::string sLogFile;
	std::string sLogFilter;
	std::string sLogFormat;
	std::string sDebianLocation;
	std::string sDebianType;
	std::string sDBHost;
	std::string sDBDatabase;
	uint32_t uiDBPort;
	std::string sDBUser;
	std::string sDBPassword;

	boost::filesystem::path idir;
	// capture the directory from which urpackager was run.
	// we return the user to this directory when we exit.
	idir = boost::filesystem::initial_path();

	// work is run out of the users home directory
	sWorkingDir = getenv("HOME");
	if (sWorkingDir.empty()) // not a  popular linux version configuration
		sWorkingDir = getenv("USERPROFILE");
	if (sWorkingDir.empty()) {
		std::cout << "The user running this utility must have a home directory" << std::endl;
		return (ERROR_FILESYSTEM);
	}

	// If this is the first time run, configuration file and control files will not exist
	sWorkingDir += "/.urpackager";
	boost::filesystem::path wdir(sWorkingDir);
	if (!boost::filesystem::is_directory(wdir)) { // First time the utility was run by this user.
		if (!boost::filesystem::create_directory(wdir)) {
			std::cout << "Unable to write to the user's home directory" << std::endl;
			return (ERROR_FILESYSTEM);
		}
		boost::filesystem::current_path(wdir);
		boost::filesystem::create_directory("./pkgcontrol");
		boost::filesystem::create_directory("./log");
		urpackagerConfFileCreate();
		std::cout << "This is the first time you have run \"urpackager.\"" << std::endl;
		std::cout << "Edit the file '~/.urpackager/urpackager.conf'" << std::endl;
		return (EXEC_SUCCESS);
	}
	boost::filesystem::current_path(wdir);

	// get run parameters
	try {
		/** Define and parse the program options */
		boost::program_options::options_description generic("Generic Options", 255); // command line only options
		generic.add_options()
				("help,h", "Print help messages")
				("version,v", "Version 1.0.0");

		boost::program_options::options_description config("Configuration Options"); // command line or configuration file and environment
		config.add_options()
		("package", boost::program_options::value<std::string>(),
				"The name of the package for which to create a debian")
		("architecture", boost::program_options::value<std::string>(),
				"Architecture for which you wish to create a debian file")
		("section", boost::program_options::value<std::string>()->default_value("amd64"),
				"repository section for which you wish to create a debian file")
		("test", boost::program_options::value<bool>()->default_value(false),
				"prints out variables but does no work")
		("stagedir", boost::program_options::value<std::string>()->default_value("unique_path"),
				"The directory under which the debian manifest will be temporarily created")
		("installprefix", boost::program_options::value<std::string>()->default_value("/opt/magni/v4"),
				"Prefix directory into which files will be (default) installed")
		("config", boost::program_options::value<std::string>()->default_value("./urpackager.conf"),
				"The configuration file")
		("log.file", boost::program_options::value<std::string>()->default_value("./log/urpackager.log"),
				"The log file")
		("log.filter", boost::program_options::value<std::string>()->default_value("INFO"),
				"The log level")
		("log.rotationsize", boost::program_options::value<int>()->default_value(100),
				"The maximum size for the log file in MB")
		("log.format", boost::program_options::value<std::string>()->default_value("[%TimeStamp%]: %Message%"),
				"The format log messages take")
		("ros.version", boost::program_options::value<std::string>()->default_value("indigo"),
				"The version of ROS this build - appended to <run_depend> package names")
		("debian.type", boost::program_options::value<std::string>()->default_value("deb"),
				"Package either a binary (type = \"deb\") or a micro binary (type = \"udeb\")")
		("debian.location", boost::program_options::value<std::string>(),
				"Directory into which to place the debian file")
    ("database.host", boost::program_options::value<std::string>(),
	      "The host where the urpackage db is running")
    ("database.database", boost::program_options::value<std::string>(),
        "The mysql schema")
    ("database.port", boost::program_options::value<int>(),
        "The port on which the database is listening")
    ("database.user", boost::program_options::value<std::string>(),
        "The user of the database")
    ("database.password", boost::program_options::value<std::string>(),
        "Password to log into the database");
		boost::program_options::options_description hidden("Hidden"); // command line or configuration file/environment but not shown

		hidden.add_options()("administrator", boost::program_options::value<std::string>(),
				"Administration capabilities");

		boost::program_options::options_description cmdline_options;
		cmdline_options.add(generic).add(config).add(hidden);

		boost::program_options::options_description cfgfile_options;
		cfgfile_options.add(config).add(hidden);

		boost::program_options::options_description visible("Allowed options");
		visible.add(generic).add(config);

    boost::program_options::store(boost::program_options::parse_command_line(argc, argv, cmdline_options), vm); // can throw

		/* --help option */
		if (vm.count("help")) {
			std::cout << "Foo help...." << std::endl
					<< config << std::endl;
			graceful_exit(idir, EXEC_SUCCESS);
		}

		if (vm.count("version")) {
			std::cout << "urpackager Version 1.0.0" << std::endl
					<< config << std::endl;
			graceful_exit(idir, EXEC_SUCCESS);
		}

		if (vm.count("package")) {
			sPackageName = vm["package"].as<std::string>();
		}

		if (vm.count("architecture")) {
			sArchitecture = vm["architecture"].as<std::string>();
		}

		if (vm.count("section")) {
			sSection = vm["section"].as<std::string>();
		}

		if (vm.count("test")) {
			bTest = vm["test"].as<bool>();
		}

		if (vm.count("stagedir")) {
			sStageDir = vm["stagedir"].as<std::string>();
		}

		if (vm.count("installprefix")) {
			sInstallPrefix = vm["installprefix"].as<std::string>();
		}

		if (vm.count("config"))
			sCfgfile = (const std::string&) vm["config"].as<std::string>();

		std::ifstream cfgfile(sCfgfile.c_str(), std::ios::in);
		if (cfgfile.fail())
			std::cout << "Config file failed to open" << std::endl;

		boost::program_options::store(parse_config_file(cfgfile, cfgfile_options, true), vm);
		cfgfile.close();

		boost::program_options::notify(vm); // throws on error, so do after help in case
		// there are any problems
	} catch (boost::program_options::error& e) {
		std::cerr << "ERROR: " << e.what() << std::endl << std::endl;
		graceful_exit(idir, ERROR_COMMAND_LINE);
	}

	try {
		if (vm.count("log.file"))
			sLogFile = (const std::string&) vm["log.file"].as<std::string>();

		if (vm.count("log.filter"))
			sLogFilter = (const std::string&) vm["log.filter"].as<std::string>();

		if (vm.count("log.rotationsize"))
			iLogRotationSize = (int) vm["log.rotationsize"].as<int>();

		if (vm.count("log.format"))
			sLogFormat = (const std::string&) vm["log.format"].as<std::string>();

		if (vm.count("debian.location"))
			sDebianLocation = (const std::string&) vm["debian.location"].as<std::string>();

		if (vm.count("debian.type"))
			sDebianType = (const std::string&) vm["debian.type"].as<std::string>();

		if (vm.count("ros.version"))
			sRosVersion = (const std::string&) vm["ros.version"].as<std::string>();

		if (sPackageName.empty()) {
			std::cout << "Execution of this utility requires a package name" << std::endl;
			graceful_exit(idir, ERROR_COMMAND_LINE);
		}

		if (sArchitecture.empty()) {
			sPackageControlFile = sWorkingDir + "/pkgcontrol/"
					              + sPackageName + ".pkgctl";
		} else {
			sPackageControlFile = sWorkingDir + "/pkgcontrol/" + sPackageName +
					              "." + sArchitecture + ".pkgctl";
		}
    if (vm.count("database.host"))
      sDBHost = (const std::string&) vm["database.host"].as<std::string>();

    if (vm.count("database.database"))
      sDBDatabase = (const std::string&) vm["database.database"].as<std::string>();

    if (vm.count("database.port"))
      uiDBPort = (unsigned int) vm["database.port"].as<int>();

    if (vm.count("database.user"))
      sDBUser = (const std::string&) vm["database.user"].as<std::string>();

    if (vm.count("database.password"))
      sDBPassword = (const std::string&) vm["database.password"].as<std::string>();

	} catch (std::exception& e) {
		std::cerr << "Unhandled Exception reached after applying all options: "
				<< e.what() << ", application will now exit" << std::endl;
		graceful_exit(idir, ERROR_UNHANDLED_EXCEPTION);
	}

	/* Ready to run the utility
	 *
	 */
	ur::PackageControl pc(sPackageControlFile);
	pc.readControlFile();
	pc.setStageBase(sStageDir);
	ur::PackageXML px;
	px.readFile(pc.getPackageXML());

	if(bTest) {
		graceful_exit(idir, EXEC_SUCCESS);
	}

	ur::DebianPackage pkg(pc, px,
			              sArchitecture,
					      sSection,
					      sDebianType,
					      sDebianLocation,
					      sDBHost,
					      sDBDatabase,
					      sDBUser,
					      sDBPassword,
					      uiDBPort);

	pkg.createStageDirectory();
	pkg.stageManifest();
	pkg.writeDebianControleFile();
	pkg.generateChecksums();
	pkg.generateDebianPackage();
	pkg.moveDebianPackage();
	pkg.deleteStaging();

	return (EXEC_SUCCESS);
}
void MetaspaceShared::generate_vtable_methods(void** vtbl_list,
                                                   void** vtable,
                                                   char** md_top,
                                                   char* md_end,
                                                   char** mc_top,
                                                   char* mc_end) {

  intptr_t vtable_bytes = (num_virtuals * vtbl_list_size) * sizeof(void*);
  *(intptr_t *)(*md_top) = vtable_bytes;
  *md_top += sizeof(intptr_t);
  void** dummy_vtable = (void**)*md_top;
  *vtable = dummy_vtable;
  *md_top += vtable_bytes;

  // Get ready to generate dummy methods.

  CodeBuffer cb((unsigned char*)*mc_top, mc_end - *mc_top);
  MacroAssembler* masm = new MacroAssembler(&cb);

  Label common_code;
  for (int i = 0; i < vtbl_list_size; ++i) {
    for (int j = 0; j < num_virtuals; ++j) {
      dummy_vtable[num_virtuals * i + j] = (void*)masm->pc();

      // Load rax, with a value indicating vtable/offset pair.
      // -- bits[ 7..0]  (8 bits) which virtual method in table?
      // -- bits[12..8]  (5 bits) which virtual method table?
      // -- must fit in 13-bit instruction immediate field.
      __ movl(rax, (i << 8) + j);
      __ jmp(common_code);
    }
  }

  __ bind(common_code);

#ifdef WIN32
  // Expecting to be called with "thiscall" conventions -- the arguments
  // are on the stack, except that the "this" pointer is in rcx.
#else
  // Expecting to be called with Unix conventions -- the arguments
  // are on the stack, including the "this" pointer.
#endif

  // In addition, rax was set (above) to the offset of the method in the
  // table.

#ifdef WIN32
  __ push(rcx);                         // save "this"
#endif
  __ mov(rcx, rax);
  __ shrptr(rcx, 8);                    // isolate vtable identifier.
  __ shlptr(rcx, LogBytesPerWord);
  Address index(noreg, rcx,  Address::times_1);
  ExternalAddress vtbl((address)vtbl_list);
  __ movptr(rdx, ArrayAddress(vtbl, index)); // get correct vtable address.
#ifdef WIN32
  __ pop(rcx);                          // restore "this"
#else
  __ movptr(rcx, Address(rsp, BytesPerWord));   // fetch "this"
#endif
  __ movptr(Address(rcx, 0), rdx);      // update vtable pointer.

  __ andptr(rax, 0x00ff);                       // isolate vtable method index
  __ shlptr(rax, LogBytesPerWord);
  __ addptr(rax, rdx);                  // address of real method pointer.
  __ jmp(Address(rax, 0));              // get real method pointer.

  __ flush();

  *mc_top = (char*)__ pc();
}
Пример #18
0
bool InterruptedContext::in_system_trap() {
  if (scp == &dummy_scp)
    return false;
  // system call, sysenter instruction
  return pc()[0] == '\x0f'  &&  pc()[1] == '\x34';
}
Пример #19
0
inline void putn(int n){
	if(!n) pc('0');
	int pi = 0;
	while(n) pb[pi++] = (n%10) + '0', n /= 10;
	while(pi) pc(pb[--pi]);
}
Пример #20
0
int
main(int argc, char *argv[]) {
    nata_InitializeLogger(emit_Unknown, "", true, false, 0);

    dbgMsg("Enter.\n");

    setupSignals();
    ProcessJanitor::initialize();

    myArgs opts(argv[0]);
    if (opts.parse(argc - 1, argv + 1) != true) {
        return 1;
    }

    char * const *cppOpts = opts.getCppOptions();
    char * const *ldOpts = opts.getLinkerOptions();
    char * const *cp;
    const char * const *newArgv = NULL;
    int newArgc = 0;

    opts.getUnparsedOptions(newArgc, newArgv);

    if (cppOpts != NULL) {
        cp = cppOpts;
        fprintf(stderr, "CPPFLAGS = ");
        while (*cp != NULL) {
            fprintf(stderr, "%s ", *cp);
            cp++;
        }
        fprintf(stderr, "\n");
    }

    if (ldOpts != NULL) {
        cp = ldOpts;
        fprintf(stderr, "LDFLAGS = ");
        while (*cp != NULL) {
            fprintf(stderr, "%s ", *cp);
            cp++;
        }
        fprintf(stderr, "\n");
    }

    if (newArgc > 0) {
        int i;
        fprintf(stderr, "other = ");
        for (i = 0; i < newArgc; i++) {
            fprintf(stderr, "%s ", newArgv[i]);
        }
        fprintf(stderr, "\n");
    }

    return 0;

    const char * const cmd0[] = {
        "cat", "/etc/passwd", NULL
    };
    const char * const cmd1[] = {
        "sed", "s/^[a-zA-Z_][a-zA-Z0-9_\\-]*:/XXXXXXXX:/g", NULL
    };
    const char * const cmd2[] = {
        "cat", "-n", NULL
    };

    PipelinedCommands pc(-1, 1, 2);
    pc.addCommand(NULL, cmd0[0], (char * const *)cmd0);
    pc.addCommand(NULL, cmd1[0], (char * const *)cmd1);
    pc.addCommand(NULL, cmd2[0], (char * const *)cmd2);

    pc.start();

    return 0;
}
Пример #21
0
void MacroAssembler::store_Metadata(Metadata* md) {
  code_section()->relocate(pc(), metadata_Relocation::spec_for_immediate());
  emit_address((address) md);
}
Пример #22
0
bool game_launcher::init_lua_script()
{
	bool error = false;

	std::cerr << "Checking lua scripts... ";

	if (cmdline_opts_.script_unsafe_mode) {
		plugins_manager::get()->get_kernel_base()->load_package(); //load the "package" package, so that scripts can get what packages they want
	}

	// get the application lua kernel, load and execute script file, if script file is present
	if (cmdline_opts_.script_file)
	{
		filesystem::scoped_istream sf = filesystem::istream_file(*cmdline_opts_.script_file);

		if (!sf->fail()) {
			/* Cancel all "jumps" to editor / campaign / multiplayer */
			jump_to_multiplayer_ = false;
			jump_to_editor_ = false;
			jump_to_campaign_.jump_ = false;

			std::string full_script((std::istreambuf_iterator<char>(*sf)), std::istreambuf_iterator<char>());

			std::cerr << "\nRunning lua script: " << *cmdline_opts_.script_file << std::endl;

			plugins_manager::get()->get_kernel_base()->run(full_script.c_str());
		} else {
			std::cerr << "Encountered failure when opening script '" << *cmdline_opts_.script_file << "'\n";
			error = true;
		}
	}

	if (cmdline_opts_.plugin_file)
	{
		std::string filename = *cmdline_opts_.plugin_file;

		std::cerr << "Loading a plugin file'" << filename << "'...\n";

		filesystem::scoped_istream sf = filesystem::istream_file(filename);

		try {
			if (sf->fail()) {
				throw std::runtime_error("failed to open plugin file");
			}

			/* Cancel all "jumps" to editor / campaign / multiplayer */
			jump_to_multiplayer_ = false;
			jump_to_editor_ = false;
			jump_to_campaign_.jump_ = false;

			std::string full_plugin((std::istreambuf_iterator<char>(*sf)), std::istreambuf_iterator<char>());

			plugins_manager & pm = *plugins_manager::get();

			size_t i = pm.add_plugin(filename, full_plugin);

			for (size_t j = 0 ; j < pm.size(); ++j) {
				std::cerr << j << ": " << pm.get_name(j) << " -- " << pm.get_detailed_status(j) << std::endl;
			}

			std::cerr << "Starting a plugin...\n";
			pm.start_plugin(i);

			for (size_t j = 0 ; j < pm.size(); ++j) {
				std::cerr << j << ": " << pm.get_name(j) << " -- " << pm.get_detailed_status(j) << std::endl;
			}

			plugins_context pc("init");

			for (size_t repeat = 0; repeat < 5; ++repeat) {
				std::cerr << "Playing a slice...\n";
				pc.play_slice();

				for (size_t j = 0 ; j < pm.size(); ++j) {
					std::cerr << j << ": " << pm.get_name(j) << " -- " << pm.get_detailed_status(j) << std::endl;
				}
			}

			return true;
		} catch (std::exception & e) {
			gui2::show_error_message(video(), std::string("When loading a plugin, error:\n") + e.what());
			error = true;
		}
	}

	if (!error) {
		std::cerr << "ok\n";
	}

	return !error;
}
Пример #23
0
static char
dialit(char *phonenum, char *acu)
{
	struct vaconfig *vp;
	struct termios cntrl;
	char c;
	int i;

	phonenum = sanitize(phonenum);
#ifdef DEBUG
	(void) printf("(dial phonenum=%s)\n", phonenum);
#endif
	if (*phonenum == '<' && phonenum[1] == 0)
		return ('Z');
	for (vp = vaconfig; vp->vc_name; vp++)
		if (strcmp(vp->vc_name, acu) == 0)
			break;
	if (vp->vc_name == 0) {
		(void) printf("Unable to locate dialer (%s)\n", acu);
		return ('K');
	}
	(void) ioctl(AC, TCGETS, &cntrl);
	(void) cfsetospeed(&cntrl, B0);
	(void) cfsetispeed(&cntrl, B0);
	cntrl.c_cflag &= ~(CSIZE|PARENB|PARODD);
	(void) cfsetospeed(&cntrl, B2400);
	cntrl.c_cflag |= CS8;
	cntrl.c_iflag &= IXOFF|IXANY;
	cntrl.c_lflag &= ~(ICANON|ISIG);
	cntrl.c_oflag = 0;
	cntrl.c_cc[VMIN] = cntrl.c_cc[VTIME] = 0;
	(void) ioctl(AC, TCSETSF, &cntrl);
	(void) ioctl(AC, TCFLSH, TCOFLUSH);
	pc(STX);
	pc(vp->vc_rack);
	pc(vp->vc_modem);
	while (*phonenum && *phonenum != '<')
		pc(*phonenum++);
	pc(SI);
	pc(ETX);
	(void) sleep(1);
	i = read(AC, &c, 1);
#ifdef DEBUG
	printf("read %d chars, char=%c, errno %d\n", i, c, errno);
#endif
	if (i != 1)
		c = 'M';
	if (c == 'B' || c == 'G') {
		char cc, oc = c;

		pc(ABORT);
		(void) read(AC, &cc, 1);
#ifdef DEBUG
		(void) printf("abort response=%c\n", cc);
#endif
		c = oc;
		v831_disconnect();
	}
	(void) close(AC);
#ifdef DEBUG
	(void) printf("dialit: returns %c\n", c);
#endif
	return (c);
}
TEST_F(LoadPlanningModelsPr2, IKConstraintsSamplerSimple)
{
  robot_state::Transforms &tf = ps->getTransformsNonConst();

  kinematic_constraints::PositionConstraint pc(kmodel);
  moveit_msgs::PositionConstraint pcm;

  pcm.link_name = "l_wrist_roll_link";
  pcm.target_point_offset.x = 0;
  pcm.target_point_offset.y = 0;
  pcm.target_point_offset.z = 0;
  pcm.constraint_region.primitives.resize(1);
  pcm.constraint_region.primitives[0].type = shape_msgs::SolidPrimitive::SPHERE;
  pcm.constraint_region.primitives[0].dimensions.resize(1);
  pcm.constraint_region.primitives[0].dimensions[0] = 0.001;

  pcm.constraint_region.primitive_poses.resize(1);
  pcm.constraint_region.primitive_poses[0].position.x = 0.55;
  pcm.constraint_region.primitive_poses[0].position.y = 0.2;
  pcm.constraint_region.primitive_poses[0].position.z = 1.25;
  pcm.constraint_region.primitive_poses[0].orientation.x = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.y = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.z = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.w = 1.0;
  pcm.weight = 1.0;

  EXPECT_FALSE(pc.configure(pcm, tf));

  constraint_samplers::IKConstraintSampler ik_bad(ps, "l_arm");
  EXPECT_FALSE(ik_bad.isValid());

  constraint_samplers::IKConstraintSampler iks(ps, "left_arm");
  EXPECT_FALSE(iks.configure(constraint_samplers::IKSamplingPose()));
  EXPECT_FALSE(iks.isValid());

  EXPECT_FALSE(iks.configure(constraint_samplers::IKSamplingPose(pc)));

  pcm.header.frame_id = kmodel->getModelFrame();
  EXPECT_TRUE(pc.configure(pcm, tf));
  EXPECT_TRUE(iks.configure(constraint_samplers::IKSamplingPose(pc)));

  //ik link not in this group
  constraint_samplers::IKConstraintSampler ik_bad_2(ps, "right_arm");
  EXPECT_FALSE(ik_bad_2.configure(constraint_samplers::IKSamplingPose(pc)));
  EXPECT_FALSE(ik_bad_2.isValid());

  //not the ik link
  pcm.link_name = "l_shoulder_pan_link";
  EXPECT_TRUE(pc.configure(pcm, tf));
  EXPECT_FALSE(iks.configure(constraint_samplers::IKSamplingPose(pc)));

  //solver for base doesn't cover group
  constraint_samplers::IKConstraintSampler ik_base(ps, "base");
  pcm.link_name = "l_wrist_roll_link";
  EXPECT_TRUE(pc.configure(pcm, tf));
  EXPECT_FALSE(ik_base.configure(constraint_samplers::IKSamplingPose(pc)));
  EXPECT_FALSE(ik_base.isValid());

  //shouldn't work as no direct constraint solver
  constraint_samplers::IKConstraintSampler ik_arms(ps, "arms");
  EXPECT_FALSE(iks.isValid());
}
Пример #25
0
int main(int argc, char* argv[])
{
	char tmp[1000];
	int fd, nread,i;
	char buf[BUF_SIZE];
	struct linux_dirent *d;
	int bpos;
	char d_type;
	int argLen=0;
	char* args[1024];
	localtime();
	for(i=1;i<argc;i++)
		if(argv[i][0]=='-')
		{
			int k=1;
			while(argv[i][k])
			{
				if(argv[i][k]=='a')
					fa=1;
				else if(argv[i][k]=='l')
					fl=1;
				else if(argv[i][k]=='h')
					fh=1;
				k++;
			}
		}
		else
			args[argLen++]=argv[i];
	if(argLen==0)
		args[argLen++]=".";
	for(i=0;i<argLen;i++)
	{
		write(1,args[i],getLen(args[i]));
		write(1,": \n",3);
		fd = open(args[i], O_RDONLY | O_DIRECTORY);
		if (fd == -1)
			handle_error("open");

		for ( ; ; ) {
			nread = syscall(SYS_getdents, fd, buf, BUF_SIZE);
			if (nread == -1)
				handle_error("getdents");
			if (nread == 0)
				break;
			for (bpos = 0; bpos < nread;) {
				struct stat sb;
				d = (struct linux_dirent *) (buf + bpos);
				d_type = *(buf + bpos + d->d_reclen - 1);
				char jj[10000],slash[2];
				slash[0]='/';
				slash[1]='\0';
				jj[0]='\0';
				mycat(jj,args[i]); if(jj[getLen(jj)-1]!='/') mycat(jj,slash); mycat(jj,d->d_name);
				if(!fa && !fl)
				{
					if(d->d_name[0]!='.')
					{
						lstat(jj,&sb);
						color = d_type == DT_LNK ? 3 : d_type == DT_DIR ? 2 : sb.st_mode & S_IXUSR ? 1 : 0;
						pc(color);
						write(1,("%s",d->d_name),getLen(d->d_name));
						pc(0);
						write(1,"\n",1);
					}
				}
				else if(fa && !fl)
				{
					lstat(jj,&sb);
					color = d_type == DT_LNK ? 3 : d_type == DT_DIR ? 2 : sb.st_mode & S_IXUSR ? 1 : 0;
					pc(color);
					write(1,("%s",d->d_name),getLen(d->d_name));
					pc(0);
					write(1,"\n",1);
				}
				else if(fa || fl)
				{
					if(!fa && d->d_name[0]=='.')
					{
						bpos += d->d_reclen;
						continue;
					}
					lstat(jj,&sb);

					if(DT_LNK == d_type) write(1,"l",1);
					else if(DT_DIR == d_type) write(1,"d",1);
					else if(DT_BLK == d_type) write(1,"b",1);
					else if(DT_SOCK == d_type) write(1,"s",1);
					else if(DT_CHR == d_type) write(1,"?",1);
					else write(1,"-",1);
					write( 1,("%s",(sb.st_mode & S_IRUSR) ? "r" : "-") ,1);
					write( 1,("%s",(sb.st_mode & S_IWUSR) ? "w" : "-") ,1);
					write( 1,("%s",(sb.st_mode & S_IXUSR) ? "x" : "-") ,1);
					write( 1,("%s",(sb.st_mode & S_IRGRP) ? "r" : "-") ,1);
					write( 1,("%s",(sb.st_mode & S_IWGRP) ? "w" : "-") ,1);
					write( 1,("%s",(sb.st_mode & S_IXGRP) ? "x" : "-") ,1);
					write( 1,("%s",(sb.st_mode & S_IROTH) ? "r" : "-") ,1);
					write( 1,("%s",(sb.st_mode & S_IWOTH) ? "w" : "-") ,1);
					write( 1,("%s",(sb.st_mode & S_IXOTH) ? "x" : "-") ,1);
					itos(sb.st_nlink,tmp);
					print(tmp,0);
					getId(sb.st_uid, 0);
					print(rStr,10);
					getId(sb.st_gid, 1);
					print(rStr,10);
					if(fh) 
					{
						int cnt=0;
						char kk[1000];
						kk[0]='\0';
						long long int t = sb.st_size,p=0;
						while(t/1024)
						{
							p=t%1024;
							t/=1024;
							cnt++;
						}
						itos(t,tmp);
						mycat(kk,tmp);
						tmp[0]='.';
						tmp[1]='\0';
						mycat(kk,tmp);
						itos(p,tmp);
						tmp[2]='\0';
						mycat(kk,tmp);
						if(cnt==1)
						{
							tmp[0]='K';
							tmp[1]='\0';
							mycat(kk,tmp);
						}
						else if(cnt==2)
						{
							tmp[0]='M';
							tmp[1]='b';
							tmp[2]='\0';
							mycat(kk,tmp);
						}
						else if(cnt>=3)
						{
							tmp[0]='G';
							tmp[1]='b';
							tmp[2]='\0';
							mycat(kk,tmp);
						}
						print(kk,11);
					}
					else
					{
						itos(sb.st_size,tmp);
						print(tmp,8);
					}
					convert(sb.st_mtime);
					print(mon[mnth],0);
					itos(day,tmp);
					print(tmp,0);
					itos(hh,tmp);
					print(tmp,2);
					write(1,":",1);
					itos(min,tmp);
					print(tmp,3);
					color = d_type == DT_LNK ? 3 : d_type == DT_DIR ? 2 : sb.st_mode & S_IXUSR ? 1 : 0;
					pc(color);
					print(d->d_name,0);
					pc(0);
					if(d_type == DT_LNK)
					{
						char slink[1000];
						readlink(jj,slink,sb.st_size+1);
						write(1," ->",3);
						print(slink,0);
					}
					write(1,"\n",1);
					day=1; y=1970; mnth=1;yy=0;mm=0;dd=0;color=0;
				}
				bpos += d->d_reclen;
			}
		}
	}
	return 0;
}
TEST_F(LoadPlanningModelsPr2, IKConstraintsSamplerValid)
{
  robot_state::RobotState ks(kmodel);
  ks.setToDefaultValues();
  ks.update();
  robot_state::RobotState ks_const(kmodel);
  ks_const.setToDefaultValues();
  ks_const.update();

  robot_state::Transforms &tf = ps->getTransformsNonConst();

  kinematic_constraints::PositionConstraint pc(kmodel);
  moveit_msgs::PositionConstraint pcm;

  pcm.link_name = "l_wrist_roll_link";
  pcm.target_point_offset.x = 0;
  pcm.target_point_offset.y = 0;
  pcm.target_point_offset.z = 0;
  pcm.constraint_region.primitives.resize(1);
  pcm.constraint_region.primitives[0].type = shape_msgs::SolidPrimitive::SPHERE;
  pcm.constraint_region.primitives[0].dimensions.resize(1);
  pcm.constraint_region.primitives[0].dimensions[0] = 0.001;

  pcm.header.frame_id = kmodel->getModelFrame();

  pcm.constraint_region.primitive_poses.resize(1);
  pcm.constraint_region.primitive_poses[0].position.x = 0.55;
  pcm.constraint_region.primitive_poses[0].position.y = 0.2;
  pcm.constraint_region.primitive_poses[0].position.z = 1.25;
  pcm.constraint_region.primitive_poses[0].orientation.x = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.y = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.z = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.w = 1.0;
  pcm.weight = 1.0;

  EXPECT_TRUE(pc.configure(pcm, tf));

  kinematic_constraints::OrientationConstraint oc(kmodel);
  moveit_msgs::OrientationConstraint ocm;

  ocm.link_name = "l_wrist_roll_link";
  ocm.header.frame_id = kmodel->getModelFrame();
  ocm.orientation.x = 0.0;
  ocm.orientation.y = 0.0;
  ocm.orientation.z = 0.0;
  ocm.orientation.w = 1.0;
  ocm.absolute_x_axis_tolerance = 0.2;
  ocm.absolute_y_axis_tolerance = 0.1;
  ocm.absolute_z_axis_tolerance = 0.4;
  ocm.weight = 1.0;

  EXPECT_TRUE(oc.configure(ocm, tf));

  constraint_samplers::IKConstraintSampler iks1(ps, "left_arm");
  EXPECT_TRUE(iks1.configure(constraint_samplers::IKSamplingPose(pc, oc)));
  for (int t = 0 ; t < 100 ; ++t)
  {
    EXPECT_TRUE(iks1.sample(ks, ks_const, 100));
    EXPECT_TRUE(pc.decide(ks).satisfied);
    EXPECT_TRUE(oc.decide(ks).satisfied);
  }

  constraint_samplers::IKConstraintSampler iks2(ps, "left_arm");
  EXPECT_TRUE(iks2.configure(constraint_samplers::IKSamplingPose(pc)));
  for (int t = 0 ; t < 100 ; ++t)
  {
    EXPECT_TRUE(iks2.sample(ks, ks_const, 100));
    EXPECT_TRUE(pc.decide(ks).satisfied);
  }

  constraint_samplers::IKConstraintSampler iks3(ps, "left_arm");
  EXPECT_TRUE(iks3.configure(constraint_samplers::IKSamplingPose(oc)));
  for (int t = 0 ; t < 100 ; ++t)
  {
    EXPECT_TRUE(iks3.sample(ks, ks_const, 100));
    EXPECT_TRUE(oc.decide(ks).satisfied);
  }
}
void
DropDownListClientWKC::updateFromElement(WebCore::PopupMenuClient *client)
{
    PopupMenuClientPrivate pc(client);
    m_appClient->updateFromElement(&pc.wkc());
}
TEST_F(LoadPlanningModelsPr2, UnionConstraintSampler)
{
  robot_state::RobotState ks(kmodel);
  ks.setToDefaultValues();
  ks.update();

  robot_state::RobotState ks_const(kmodel);
  ks_const.setToDefaultValues();
  ks_const.update();

  robot_state::Transforms &tf = ps->getTransformsNonConst();

  kinematic_constraints::JointConstraint jc1(kmodel);

  std::map<std::string, double> state_values;

  moveit_msgs::JointConstraint torso_constraint;
  torso_constraint.joint_name = "torso_lift_joint";
  torso_constraint.position = ks.getVariablePosition("torso_lift_joint");
  torso_constraint.tolerance_above = 0.01;
  torso_constraint.tolerance_below = 0.01;
  torso_constraint.weight = 1.0;
  EXPECT_TRUE(jc1.configure(torso_constraint));

  kinematic_constraints::JointConstraint jc2(kmodel);
  moveit_msgs::JointConstraint jcm2;
  jcm2.joint_name = "r_elbow_flex_joint";
  jcm2.position = ks.getVariablePosition("r_elbow_flex_joint");
  jcm2.tolerance_above = 0.01;
  jcm2.tolerance_below = 0.01;
  jcm2.weight = 1.0;
  EXPECT_TRUE(jc2.configure(jcm2));

  moveit_msgs::PositionConstraint pcm;

  pcm.link_name = "l_wrist_roll_link";
  pcm.target_point_offset.x = 0;
  pcm.target_point_offset.y = 0;
  pcm.target_point_offset.z = 0;
  pcm.constraint_region.primitives.resize(1);
  pcm.constraint_region.primitives[0].type = shape_msgs::SolidPrimitive::SPHERE;
  pcm.constraint_region.primitives[0].dimensions.resize(1);
  pcm.constraint_region.primitives[0].dimensions[0] = 0.001;

  pcm.constraint_region.primitive_poses.resize(1);
  pcm.constraint_region.primitive_poses[0].position.x = 0.55;
  pcm.constraint_region.primitive_poses[0].position.y = 0.2;
  pcm.constraint_region.primitive_poses[0].position.z = 1.25;
  pcm.constraint_region.primitive_poses[0].orientation.x = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.y = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.z = 0.0;
  pcm.constraint_region.primitive_poses[0].orientation.w = 1.0;
  pcm.weight = 1.0;

  pcm.header.frame_id = kmodel->getModelFrame();

  moveit_msgs::OrientationConstraint ocm;

  ocm.link_name = "l_wrist_roll_link";
  ocm.header.frame_id = kmodel->getModelFrame();
  ocm.orientation.x = 0.0;
  ocm.orientation.y = 0.0;
  ocm.orientation.z = 0.0;
  ocm.orientation.w = 1.0;
  ocm.absolute_x_axis_tolerance = 0.2;
  ocm.absolute_y_axis_tolerance = 0.1;
  ocm.absolute_z_axis_tolerance = 0.4;
  ocm.weight = 1.0;

  std::vector<kinematic_constraints::JointConstraint> js;
  js.push_back(jc1);

  boost::shared_ptr<constraint_samplers::JointConstraintSampler> jcsp(new constraint_samplers::JointConstraintSampler(ps, "arms_and_torso"));
  EXPECT_TRUE(jcsp->configure(js));

  std::vector<kinematic_constraints::JointConstraint> js2;
  js2.push_back(jc2);

  boost::shared_ptr<constraint_samplers::JointConstraintSampler> jcsp2(new constraint_samplers::JointConstraintSampler(ps, "arms"));
  EXPECT_TRUE(jcsp2->configure(js2));

  kinematic_constraints::PositionConstraint pc(kmodel);
  EXPECT_TRUE(pc.configure(pcm, tf));

  kinematic_constraints::OrientationConstraint oc(kmodel);
  EXPECT_TRUE(oc.configure(ocm, tf));

  boost::shared_ptr<constraint_samplers::IKConstraintSampler> iksp(new constraint_samplers::IKConstraintSampler(ps, "left_arm"));
  EXPECT_TRUE(iksp->configure(constraint_samplers::IKSamplingPose(pc, oc)));
  EXPECT_TRUE(iksp->isValid());

  std::vector<constraint_samplers::ConstraintSamplerPtr> cspv;
  cspv.push_back(jcsp2);
  cspv.push_back(iksp);
  cspv.push_back(jcsp);

  constraint_samplers::UnionConstraintSampler ucs(ps, "arms_and_torso", cspv);

  //should have reordered to place whole body first
  constraint_samplers::JointConstraintSampler* jcs = dynamic_cast<constraint_samplers::JointConstraintSampler*>(ucs.getSamplers()[0].get());
  EXPECT_TRUE(jcs);
  EXPECT_EQ(jcs->getJointModelGroup()->getName(), "arms_and_torso");

  constraint_samplers::JointConstraintSampler* jcs2 = dynamic_cast<constraint_samplers::JointConstraintSampler*>(ucs.getSamplers()[1].get());
  EXPECT_TRUE(jcs2);
  EXPECT_EQ(jcs2->getJointModelGroup()->getName(), "arms");

  for (int t = 0 ; t < 100; ++t)
  {
    EXPECT_TRUE(ucs.sample(ks, ks_const, 100));
    ks.update();
    ks_const.update();
    EXPECT_TRUE(jc1.decide(ks).satisfied);
    EXPECT_TRUE(jc2.decide(ks).satisfied);
    EXPECT_TRUE(pc.decide(ks).satisfied);
  }

  //now we add a position constraint on right arm
  pcm.link_name = "r_wrist_roll_link";
  ocm.link_name = "r_wrist_roll_link";
  cspv.clear();

  kinematic_constraints::PositionConstraint pc2(kmodel);
  EXPECT_TRUE(pc2.configure(pcm, tf));

  kinematic_constraints::OrientationConstraint oc2(kmodel);
  EXPECT_TRUE(oc2.configure(ocm, tf));

  boost::shared_ptr<constraint_samplers::IKConstraintSampler> iksp2(new constraint_samplers::IKConstraintSampler(ps, "right_arm"));
  EXPECT_TRUE(iksp2->configure(constraint_samplers::IKSamplingPose(pc2, oc2)));
  EXPECT_TRUE(iksp2->isValid());

  //totally disjoint, so should break ties based on alphabetical order
  cspv.clear();
  cspv.push_back(iksp2);
  cspv.push_back(iksp);

  constraint_samplers::UnionConstraintSampler ucs2(ps, "arms_and_torso", cspv);

  constraint_samplers::IKConstraintSampler* ikcs_test  = dynamic_cast<constraint_samplers::IKConstraintSampler*>(ucs2.getSamplers()[0].get());
  ASSERT_TRUE(ikcs_test);
  EXPECT_EQ(ikcs_test->getJointModelGroup()->getName(), "left_arm");

  //now we make left depends on right, right should stay first
  pcm.link_name = "l_wrist_roll_link";
  ocm.link_name = "l_wrist_roll_link";
  pcm.header.frame_id = "r_wrist_roll_link";
  ocm.header.frame_id = "r_wrist_roll_link";
  EXPECT_TRUE(pc.configure(pcm, tf));
  EXPECT_TRUE(oc.configure(ocm, tf));
  ASSERT_TRUE(iksp->configure(constraint_samplers::IKSamplingPose(pc, oc)));

  cspv.clear();
  cspv.push_back(iksp2);
  cspv.push_back(iksp);

  constraint_samplers::UnionConstraintSampler ucs3(ps, "arms_and_torso", cspv);

  ikcs_test = dynamic_cast<constraint_samplers::IKConstraintSampler*>(ucs3.getSamplers()[0].get());
  EXPECT_TRUE(ikcs_test);
  EXPECT_EQ(ikcs_test->getJointModelGroup()->getName(), "right_arm");
}
Пример #29
0
void PatchingStub::emit_code(LIR_Assembler* ce) {
  // copy original code here
  assert(NativeCall::instruction_size <= _bytes_to_copy && _bytes_to_copy <= 0xFF,
         "not enough room for call");
  assert((_bytes_to_copy & 0x3) == 0, "must copy a multiple of four bytes");

  Label call_patch;

  int being_initialized_entry = __ offset();

  if (_id == load_klass_id) {
    // produce a copy of the load klass instruction for use by the being initialized case
#ifdef ASSERT
    address start = __ pc();
#endif
    AddressLiteral addrlit(NULL, metadata_Relocation::spec(_index));
    __ patchable_set(addrlit, _obj);

#ifdef ASSERT
    for (int i = 0; i < _bytes_to_copy; i++) {
      address ptr = (address)(_pc_start + i);
      int a_byte = (*ptr) & 0xFF;
      assert(a_byte == *start++, "should be the same code");
    }
#endif
  } else if (_id == load_mirror_id || _id == load_appendix_id) {
    // produce a copy of the load mirror instruction for use by the being initialized case
#ifdef ASSERT
    address start = __ pc();
#endif
    AddressLiteral addrlit(NULL, oop_Relocation::spec(_index));
    __ patchable_set(addrlit, _obj);

#ifdef ASSERT
    for (int i = 0; i < _bytes_to_copy; i++) {
      address ptr = (address)(_pc_start + i);
      int a_byte = (*ptr) & 0xFF;
      assert(a_byte == *start++, "should be the same code");
    }
#endif
  } else {
    // make a copy the code which is going to be patched.
    for (int i = 0; i < _bytes_to_copy; i++) {
      address ptr = (address)(_pc_start + i);
      int a_byte = (*ptr) & 0xFF;
      __ emit_int8 (a_byte);
    }
  }

  address end_of_patch = __ pc();
  int bytes_to_skip = 0;
  if (_id == load_mirror_id) {
    int offset = __ offset();
    if (CommentedAssembly) {
      __ block_comment(" being_initialized check");
    }

    // static field accesses have special semantics while the class
    // initializer is being run so we emit a test which can be used to
    // check that this code is being executed by the initializing
    // thread.
    assert(_obj != noreg, "must be a valid register");
    assert(_index >= 0, "must have oop index");
    __ ld_ptr(_obj, java_lang_Class::klass_offset_in_bytes(), G3);
    __ ld_ptr(G3, in_bytes(InstanceKlass::init_thread_offset()), G3);
    __ cmp_and_brx_short(G2_thread, G3, Assembler::notEqual, Assembler::pn, call_patch);

    // load_klass patches may execute the patched code before it's
    // copied back into place so we need to jump back into the main
    // code of the nmethod to continue execution.
    __ br(Assembler::always, false, Assembler::pt, _patch_site_continuation);
    __ delayed()->nop();

    // make sure this extra code gets skipped
    bytes_to_skip += __ offset() - offset;
  }

  // Now emit the patch record telling the runtime how to find the
  // pieces of the patch.  We only need 3 bytes but it has to be
  // aligned as an instruction so emit 4 bytes.
  int sizeof_patch_record = 4;
  bytes_to_skip += sizeof_patch_record;

  // emit the offsets needed to find the code to patch
  int being_initialized_entry_offset = __ offset() - being_initialized_entry + sizeof_patch_record;

  // Emit the patch record.  We need to emit a full word, so emit an extra empty byte
  __ emit_int8(0);
  __ emit_int8(being_initialized_entry_offset);
  __ emit_int8(bytes_to_skip);
  __ emit_int8(_bytes_to_copy);
  address patch_info_pc = __ pc();
  assert(patch_info_pc - end_of_patch == bytes_to_skip, "incorrect patch info");

  address entry = __ pc();
  NativeGeneralJump::insert_unconditional((address)_pc_start, entry);
  address target = NULL;
  relocInfo::relocType reloc_type = relocInfo::none;
  switch (_id) {
    case access_field_id:  target = Runtime1::entry_for(Runtime1::access_field_patching_id); break;
    case load_klass_id:    target = Runtime1::entry_for(Runtime1::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break;
    case load_mirror_id:   target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break;
    case load_appendix_id: target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break;
    default: ShouldNotReachHere();
  }
  __ bind(call_patch);

  if (CommentedAssembly) {
    __ block_comment("patch entry point");
  }
  __ call(target, relocInfo::runtime_call_type);
  __ delayed()->nop();
  assert(_patch_info_offset == (patch_info_pc - __ pc()), "must not change");
  ce->add_call_info_here(_info);
  __ br(Assembler::always, false, Assembler::pt, _patch_site_entry);
  __ delayed()->nop();
  if (_id == load_klass_id || _id == load_mirror_id || _id == load_appendix_id) {
    CodeSection* cs = __ code_section();
    address pc = (address)_pc_start;
    RelocIterator iter(cs, pc, pc + 1);
    relocInfo::change_reloc_info_for_address(&iter, (address) pc, reloc_type, relocInfo::none);

    pc = (address)(_pc_start + NativeMovConstReg::add_offset);
    RelocIterator iter2(cs, pc, pc+1);
    relocInfo::change_reloc_info_for_address(&iter2, (address) pc, reloc_type, relocInfo::none);
  }

}
Пример #30
0
VtableStub* VtableStubs::create_itable_stub(int itable_index) {
  const int code_length = VtableStub::pd_code_size_limit(false);
  VtableStub* s = new(code_length) VtableStub(false, itable_index);
  // Can be NULL if there is no free space in the code cache.
  if (s == NULL) {
    return NULL;
  }

  ResourceMark rm;
  CodeBuffer cb(s->entry_point(), code_length);
  MacroAssembler* masm = new MacroAssembler(&cb);

  assert(VtableStub::receiver_location() == R0->as_VMReg(), "receiver expected in R0");

  // R0-R3 / R0-R7 registers hold the arguments and cannot be spoiled
  const Register Rclass  = AARCH64_ONLY(R9)  NOT_AARCH64(R4);
  const Register Rlength = AARCH64_ONLY(R10)  NOT_AARCH64(R5);
  const Register Rscan   = AARCH64_ONLY(R11) NOT_AARCH64(R6);
  const Register tmp     = Rtemp;

  assert_different_registers(Ricklass, Rclass, Rlength, Rscan, tmp);

  // Calculate the start of itable (itable goes after vtable)
  const int scale = exact_log2(vtableEntry::size_in_bytes());
  address npe_addr = __ pc();
  __ load_klass(Rclass, R0);
  __ ldr_s32(Rlength, Address(Rclass, Klass::vtable_length_offset()));

  __ add(Rscan, Rclass, in_bytes(Klass::vtable_start_offset()));
  __ add(Rscan, Rscan, AsmOperand(Rlength, lsl, scale));

  // Search through the itable for an interface equal to incoming Ricklass
  // itable looks like [intface][offset][intface][offset][intface][offset]
  const int entry_size = itableOffsetEntry::size() * HeapWordSize;
  assert(itableOffsetEntry::interface_offset_in_bytes() == 0, "not added for convenience");

  Label loop;
  __ bind(loop);
  __ ldr(tmp, Address(Rscan, entry_size, post_indexed));
#ifdef AARCH64
  Label found;
  __ cmp(tmp, Ricklass);
  __ b(found, eq);
  __ cbnz(tmp, loop);
#else
  __ cmp(tmp, Ricklass);  // set ZF and CF if interface is found
  __ cmn(tmp, 0, ne);     // check if tmp == 0 and clear CF if it is
  __ b(loop, ne);
#endif // AARCH64

  assert(StubRoutines::throw_IncompatibleClassChangeError_entry() != NULL, "Check initialization order");
#ifdef AARCH64
  __ jump(StubRoutines::throw_IncompatibleClassChangeError_entry(), relocInfo::runtime_call_type, tmp);
  __ bind(found);
#else
  // CF == 0 means we reached the end of itable without finding icklass
  __ jump(StubRoutines::throw_IncompatibleClassChangeError_entry(), relocInfo::runtime_call_type, noreg, cc);
#endif // !AARCH64

  // Interface found at previous position of Rscan, now load the method oop
  __ ldr_s32(tmp, Address(Rscan, itableOffsetEntry::offset_offset_in_bytes() - entry_size));
  {
    const int method_offset = itableMethodEntry::size() * HeapWordSize * itable_index +
      itableMethodEntry::method_offset_in_bytes();
    __ add_slow(Rmethod, Rclass, method_offset);
  }
  __ ldr(Rmethod, Address(Rmethod, tmp));

  address ame_addr = __ pc();

#ifdef AARCH64
  __ ldr(tmp, Address(Rmethod, Method::from_compiled_offset()));
  __ br(tmp);
#else
  __ ldr(PC, Address(Rmethod, Method::from_compiled_offset()));
#endif // AARCH64

  masm->flush();

  if (PrintMiscellaneous && (WizardMode || Verbose)) {
    tty->print_cr("itable #%d at " PTR_FORMAT "[%d] left over: %d",
                  itable_index, p2i(s->entry_point()),
                  (int)(s->code_end() - s->entry_point()),
                  (int)(s->code_end() - __ pc()));
  }
  guarantee(__ pc() <= s->code_end(), "overflowed buffer");
  // FIXME ARM: need correct 'slop' - below is x86 code
  // shut the door on sizing bugs
  //int slop = 8;  // 32-bit offset is this much larger than a 13-bit one
  //assert(itable_index > 10 || __ pc() + slop <= s->code_end(), "room for 32-bit offset");

  s->set_exception_points(npe_addr, ame_addr);
  return s;
}