void InterpreterStubs::generate_interpreter_timer_tick() {
  comment_section("Interpreter call timer_tick");
  entry("interpreter_timer_tick");
  interpreter_call_vm(Constant("timer_tick"), T_VOID);
  dispatch_next();
  entry_end(); // interpreter_timer_tick

#if ENABLE_PAGE_PROTECTION
  stop_code_segment();
  start_data_segment();
  if (GenerateGNUCode || GenerateInlineAsm) {
    align(PROTECTED_PAGE_SIZE);
    define_array_begin("unsigned char", "_protected_page");
    for (int i = 0; i < PROTECTED_PAGE_SIZE; i++) {
      define_byte_element(Constant(0));
    }
    define_array_end();
  } else {
    // MASM doesn't allow 4096-byte alignment,
    // so surround the protected area with 4K padding.
    // This will certainly add 8K of static footprint,
    // but who cares about the size of win32_i386 binary!
    define_byte(Constant(0), PROTECTED_PAGE_SIZE);
    define_long(Constant(0), PROTECTED_PAGE_SIZE / BytesPerWord,
                "_protected_page");
    define_byte(Constant(0), PROTECTED_PAGE_SIZE);
  }
  stop_data_segment();
  start_code_segment();
#endif
}
 virtual typename Expression<DerivType>::Ptr derivativeExpression(int i) {
     std::map<int,int>::iterator it = ndx_map.find(i);     
     if (it!=ndx_map.end()) {
         return Constant( deriv[it->second] );
     } else {
         return Constant(AutoDiffTrait<DerivType>::zeroDerivative());
     } 
 }
Expression<Vector>::Ptr RotZ_Double::derivativeExpression(int i) {
        int nr = getDep<double>(i,argument);
        if (nr==1) {
            return Constant<Vector>(Vector::Zero());
        } else {
            return KDL::vector( Constant(0.0), Constant(0.0), argument->derivativeExpression(i)  );
        }
}
Ejemplo n.º 4
0
Number Parser::createNumber(string number, char first){
    Number result;
    //This is probably lazy/ bad, but it basically makes sure that theres no junk before the actual operation.
    if (first != 's' && number.find("rt:") > 0){
        string base (number.find(':')+1, -1);
        string radicand (0, number.find('r')-1);
        result = Radical(createNumber(base, base.front()), createNumber(radicand, radicand.front()));
    }
    else if (first=='p' && number.at(1) =='i' && number.length() == 2){
        //create pi
        result = Constant("pi");
    }
    else if (first=='e' && number.length() == 1){
        //create e
        result = Constant("e");
    }
    else if (first == 's' && number.find("sqrt:") > 0){
        //create a square root
        string base (number.find(':')+1, -1);
        result = Radical(createNumber(base, base.front()), Integer(2));
    }
    else if (first == 'l' && number.find("log_") > 0){
        //create a log
        string base (number.find('_')+1, number.find(':'));
        string arg (number.find(':')+1, -1);
        result = Log(createNumber(base, base.front()), createNumber(arg, arg.front()));
    }
    //all numbers are created here
    else if (isdigit(first) && number.find_last_not_of("0123456789./") != -1){
        //find a '/' to create a fraction
        if(number.find_first_of('/') > 0){
            //check to make sure there is only one '/' in the fraction
            if (number.find_first_of('/') != number.find_last_of('/')) {
                //temporary error handling
                throw "Only one / per fracton";
            }
            //create a rational
            string numerator (0, number.find('/')-1);
            string denom ( number.find('/') + 1, -1);
            result = Rational(createNumber(numerator, numerator.front()), createNumber(denom, denom.front()));
        }
        if(number.find_first_of('.') > 0){
            if (number.find_first_of('.') != number.find_last_of('.')){
                throw "Only one . per decimal";
            }
            //create a rational from a decimal
            
            result = Rational(number));
        }
        //finally, create an integer
        result = Integer(stoi(number));
    }

    return result;
}
Ejemplo n.º 5
0
void CompilerStubs::generate_compiler_new_object() {
  comment_section("Compiler new object (any size)");
  comment("Register edx holds the instance size, register ebx holds the prototypical near of the instance class");
  Label slow_case;
  entry("compiler_new_object");

  comment("Get _inline_allocation_top");
  movl(eax, Address(Constant("_inline_allocation_top")));

  comment("Compute new top");
  leal(ecx, Address(eax, edx, times_1));

  if (GenerateDebugAssembly) {
    comment("Check ExcessiveGC");
    testl(Address(Constant("ExcessiveGC")), Constant(0));
    jcc(not_zero, Constant(slow_case));
  }

  comment("Compare against _inline_allocation_end");
  cmpl(ecx, Address(Constant("_inline_allocation_end")));
  jcc(above, Constant(slow_case));

  comment("Allocation succeeded, set _inline_allocation_top");
  movl(Address(Constant("_inline_allocation_top")), ecx);

  comment("Set prototypical near in object; no need for write barrier");
  movl(Address(eax), ebx);

  comment("Compute remaining size");
  decrement(edx, oopSize);

  comment("One-word object?");
  Label init_done;
  jcc(zero, Constant(init_done));

  comment("Zero object fields");
  xorl(ecx, ecx);
  Label init_loop;
  bind(init_loop);
  movl(Address(eax, edx, times_1), ecx);
  decrement(edx, oopSize);
  jcc(not_zero, Constant(init_loop));
  bind(init_done);

  comment("The newly allocated object is in register eax");
  ret();

  comment("Slow case - call the VM runtime system");
  bind(slow_case);
  leal(eax, Address(Constant("newobject")));
  goto_shared_call_vm(T_OBJECT);

  entry_end(); // compiler_new_object
}
void InterpreterStubs::generate_primordial_to_current_thread() {
  entry("primordial_to_current_thread");
  pushal();
  pushl(ebp);
  movl(Address(Constant("_primordial_sp")), esp);
  get_thread(ecx);
  movl(esp, Address(ecx, Constant(Thread::stack_pointer_offset())));
  popl(ebp);
  ret();
  entry_end(); // primordial_to_current_thread

  entry("start_lightweight_thread_asm");
  // Should never reach here on x86
  int3();
  entry_end(); // start_lightweight_thread_asm
}
Ejemplo n.º 7
0
 std::string Constant::to_string_impl() const
 {
     std::stringstream sst;
     sst << std::fixed;
     switch (value.type_) {
         case VT_INTEGER:
             sst << value.number;
             break;
         case VT_DOUBLE:
             sst << value.dnumber;
             break;
         case VT_GEOLOCATION:
             sst << '[' << value.geolocation.latitude << ',' << value.geolocation.longitude << ']';
             break;
         case VT_STRING:
             sst << '"' <<  value.string << '"';
             break;
         case VT_ARRAY:
             sst << '[';
             for (int i=0; i<value.array.size(); i++) {
                 sst << Constant(value.array.get_element(i)).to_string();
                 if (i!=value.array.size()-1) {
                     sst << ",";
                 }
             }
             sst << ']';
             break;
         default:
             break;
     }
     return sst.str();
 }
void InterpreterStubs::generate_interpreter_deoptimization_entry() {
  comment_section("Interpreter deoptimization entry");
  entry("interpreter_deoptimization_entry");

  // Define an interpreter call info.
  define_call_info();

  comment("Restore bytecode and locals pointers");
  movl(esi, Address(ebp, Constant(JavaFrame::bcp_store_offset())));
  movl(edi, Address(ebp, Constant(JavaFrame::locals_pointer_offset())));

  // Dispatch to the next bytecode.
  dispatch_next();

  entry_end(); // interpreter_deoptimization_entry
}
Expression<Vector>::Ptr Rot_Double::derivativeExpression(int i) {
        int nr = getDep<double>(i,argument);
        if (nr==1) {
            return Constant<Vector>(Vector::Zero());
        } else {
            return Constant( axis ) * argument->derivativeExpression(i);
        }
}
Ejemplo n.º 10
0
/**
 * Check if the initializer expression is address constant.
 * e.g. 
 * int a;
 * int b = &a;
 */
static AstExpression CheckAddressConstant(AstExpression expr)
{
	AstExpression addr;
	AstExpression p;
	int offset = 0;

	if (! IsPtrType(expr->ty))
		return NULL;

	if (expr->op == OP_ADD || expr->op == OP_SUB)
	{
		addr = CheckAddressConstant(expr->kids[0]);
		if (addr == NULL || expr->kids[1]->op != OP_CONST)
			return NULL;
		
		expr->kids[0] = addr->kids[0];
		expr->kids[1]->val.i[0] += (expr->op == OP_ADD ? 1 : -1) * addr->kids[1]->val.i[0];

		return expr;
	}

	if (expr->op == OP_ADDRESS)
		addr = expr->kids[0];
	else
		addr = expr;

	while (addr->op == OP_INDEX || addr->op == OP_MEMBER)
	{
		if (addr->op == OP_INDEX)
		{
			if (addr->kids[1]->op != OP_CONST)
				return NULL;

			offset += addr->kids[1]->val.i[0] * addr->ty->size;
		}
		else
		{
			Field fld = addr->val.p;

			offset += fld->offset;
		}
		addr = addr->kids[0];
	}

	if (addr->op != OP_ID || (expr->op != OP_ADDRESS && ! addr->isarray && ! addr->isfunc))
		return NULL;


	((Symbol)addr->val.p)->ref++;

	CREATE_AST_NODE(p, Expression);
	p->op = OP_ADD;
	p->ty = expr->ty;
	p->kids[0] = addr;
	p->kids[1] = Constant(addr->coord, T(INT), p->val);

	return p;
}
Ejemplo n.º 11
0
void KConstantEditor::cmdNew_clicked()
{
	QTreeWidgetItem * item = new QTreeWidgetItem( m_widget->constantList );
	
	init( item, XParser::self()->constants()->generateUniqueName(), Constant() );
	
	m_widget->constantList->setCurrentItem( item );
	m_widget->nameEdit->setFocus();
}
Ejemplo n.º 12
0
void SourceAssembler::define_struct_field(const char* struct_name,
                                          const char* c_type, 
                                          const char* name, 
                                          OperandSize size) {
  emit_data_name(c_type, name);
  if (GenerateInlineAsm) {
    emit(";\n");
    emit("#define %s %s.%s\n", name, struct_name, name);
  } else {
    emit_data_value(size, Constant(0));
  }
}
Ejemplo n.º 13
0
std::vector<Constant> read_constant_block(std::ifstream & stream) {
    uint16_t count = parse<uint16_t>(extract<2>(stream));
    bool skip = false;

    std::vector<Constant> constants = {Constant()}; // Initialize with an empty constant, since Java starts counting at 1.

    for (uint16_t id = 1; id < count; ++id) {
        if (skip) {
            constants.push_back(Constant());
            skip = false;
            continue;
        }

        std::pair<Constant, bool> result = read_constant(stream);

        constants.push_back(result.first);
        skip = result.second;
    }

    return constants;
}
void InterpreterStubs::generate_interpreter_call_vm_dispatch() {
  comment_section("Interpreter call VM - and dispatch to the bytecode returned by the VM upon termination");
  entry("interpreter_call_vm_dispatch");

  comment("Save bytecode pointer");
  movl(Address(ebp, Constant(JavaFrame::bcp_store_offset())), esi);

  comment("Call the shared call vm and disregard any return value");
  call_shared_call_vm(T_INT);
 
  comment("Restore bytecode pointer");
  movl(esi, Address(ebp, Constant(JavaFrame::bcp_store_offset())));

  comment("Restore locals pointer");
  movl(edi, Address(ebp, Constant(JavaFrame::locals_pointer_offset())));

  comment("Dispatch to next byte code");
  jmp(Address(no_reg, eax, times_4, Constant("interpreter_dispatch_table")));

  entry_end(); // interpreter_call_vm_dispatch
}
void InterpreterStubs::generate_interpreter_throw_exceptions() {
  comment_section("Interpreter exception throwers");

  entry("interpreter_throw_ArrayIndexOutOfBoundsException", 0);
  interpreter_call_vm(Constant("array_index_out_of_bounds_exception"), T_VOID);
  entry_end(); // interpreter_throw_ArrayIndexOutOfBoundsException

  entry("interpreter_throw_NullPointerException", 0);
  interpreter_call_vm(Constant("null_pointer_exception"), T_VOID);
  entry_end(); // interpreter_throw_NullPointerException

  entry("interpreter_throw_IllegalMonitorStateException", 0);
  interpreter_call_vm(Constant("illegal_monitor_state_exception"), T_VOID);
  entry_end(); // interpreter_throw_IllegalMonitorStateException

  entry("interpreter_throw_ArithmeticException", 0);
  interpreter_call_vm(Constant("arithmetic_exception"), T_VOID);
  entry_end(); // interpreter_throw_ArithmeticException

  entry("interpreter_throw_IncompatibleClassChangeError", 0);
  interpreter_call_vm(Constant("incompatible_class_change_error"), T_VOID);
  entry_end(); // interpreter_throw_IncompatibleClassChangeError

  if (GenerateDebugAssembly) {
    entry("interpreter_throw_InternalStackTagException", 0);
    interpreter_call_vm(Constant("internal_stack_tag_exception"), T_VOID);
    entry_end(); // interpreter_throw_InternalStackTagException
  }
}
void InterpreterStubs::generate_interpreter_call_vm_redo() {
#if ENABLE_JAVA_DEBUGGER
  Label check_breakpoint, no_breakpoint;
#endif
  comment_section("Interpreter call VM - and repeat current bytecode upon termination");
  entry("interpreter_call_vm_redo");

  comment("Save bytecode pointer");
  movl(Address(ebp, Constant(JavaFrame::bcp_store_offset())), esi);

  comment("Call the shared call vm and disregard any return value");
  call_shared_call_vm(T_VOID);
 
  comment("Restore bytecode pointer");
  movl(esi, Address(ebp, Constant(JavaFrame::bcp_store_offset())));

  comment("Restore locals pointer");
  movl(edi, Address(ebp, Constant(JavaFrame::locals_pointer_offset())));

#if ENABLE_JAVA_DEBUGGER
  comment("Check to see if we are connected to a debugger");
  cmpb(Address(Constant("_debugger_active")), Constant(0));
  jcc(not_zero, Constant(check_breakpoint));
  bind(no_breakpoint);
  comment("Not debugging, so just dispatch");
  dispatch_next(0);
  bind(check_breakpoint);
  comment("We are debugging, so let's see if we just replaced a breakpoint opcode");
  cmpb(Address(esi), Constant(Bytecodes::_breakpoint));
  jcc(not_zero, Constant(no_breakpoint));
  comment("There is a breakpoint in the code, so that means that eax has the correct opcode");
  comment("So just jmp directly without using esi");
  andl(eax, Constant(0xFF));
  movl(ebx, eax);
  jmp(Address(no_reg, ebx, times_4, Constant("interpreter_dispatch_table")));
#else
  dispatch_next(0);
#endif
  entry_end(); // interpreter_call_vm_redo
}
void InterpreterStubs::generate_interpreter_rethrow_exception_init() {
  comment_section("Interpreter rethrow exception init");
  comment("Register eax holds the exception; Interpreter state is not in registers");
  entry("interpreter_rethrow_exception_init");
#if ENABLE_JAVA_DEBUGGER
  Label skip;
  cmpb(Address(Constant("_debugger_active")), Constant(0));
  jcc(equal, Constant(skip));
  comment("push the exception object so we don't nuke it");
  push_obj(eax);
  comment("call debugger code to store relevant info about where exception happened");
  interpreter_call_vm(Constant("handle_exception_info"), T_VOID);
  pop_obj(eax, edx);
  bind(skip);
#endif
  if (GenerateInlineAsm)
      jmp(Constant("interpreter_rethrow_exception_init"));
  else
      comment("fall through to rethrow_exception"); // IMPL_NOTE: FALLTHROUGH

  entry_end(); // interpreter_rethrow_exception_init
}
void InterpreterStubs::generate_current_thread_to_primordial() {
  entry("current_thread_to_primordial");
  // We're never going to return to this thread, so it doesn't matter if
  // it doesn't look like a stopped Java thread anymore.
  // pushl(ebp);
  // get_thread(ecx);
  // movl(Address(ecx, Constant(Thread::stack_pointer_offset())), esp);
  movl(esp, Address(Constant("_primordial_sp")));
  popl(ebp);
  popal();
  ret();
  entry_end(); // current_thread_to_primordial
}
Expression<Vector>::Ptr Composition_RotationVector::derivativeExpression(int i) {
        Expression<Rotation>::Ptr arg1 = cached<Rotation>( argument1 );
        Expression<Vector>::Ptr arg2 = cached<Vector>( argument2 );
        int nr = getDep2<Rotation,Vector>(i,argument1,argument2);
        if (nr==1) {
            return Constant(Vector::Zero());
        } if (nr==2) {
           return arg1*argument2->derivativeExpression(i);
        } if (nr==3) {
           return argument1->derivativeExpression(i) * (arg1 * arg2);
        } else {
           return argument1->derivativeExpression(i) * (arg1 * arg2) + arg1*argument2->derivativeExpression(i);
        }
}
Ejemplo n.º 20
0
void Expression::apply(const std::string& name, const float& value) {
  if (!hasName(name)) {
    return;
  }
  float var_value = getValue(name);
  termList_.erase(std::remove_if(termList_.begin(),
                                 termList_.end(),
                                 [name](const std::unique_ptr<Term>& term){
                                   return term->hasName(name);
                                 }),
                  termList_.end());
  if (var_value != 0.0f) {
    add(Constant(var_value * 1.0f * value));
  }
}
Ejemplo n.º 21
0
static AstExpression TransformIncrement(AstExpression expr)
{
	AstExpression casgn;
	union value val;
	
	val.i[1] = 0; val.i[0] = 1;
	CREATE_AST_NODE(casgn, Expression);
	casgn->coord = expr->coord;
	casgn->op = (expr->op == OP_POSTINC || expr->op == OP_PREINC) ? OP_ADD_ASSIGN : OP_SUB_ASSIGN;
	casgn->kids[0] = expr->kids[0];
	casgn->kids[1] = Constant(expr->coord, T(INT), val);

	expr->kids[0] = CheckExpression(casgn);
	expr->ty = expr->kids[0]->ty;
	return expr;
}
Ejemplo n.º 22
0
/**
 * Construct an expression to divide diff by size
 */
static AstExpression PointerDifference(AstExpression diff, int size)
{
	AstExpression expr;
	union value val;

	CREATE_AST_NODE(expr, Expression);

	expr->ty = diff->ty;
	expr->op = OP_DIV;
	expr->kids[0] = diff;
	val.i[1] = 0;
	val.i[0] = size;
	expr->kids[1] = Constant(diff->coord, diff->ty, val);

	return expr;
}
Ejemplo n.º 23
0
/**
 * Construct an expression to multiply offset by scale.
 */
static AstExpression ScalePointerOffset(AstExpression offset, int scale)
{
	AstExpression expr;
	union value val;

	CREATE_AST_NODE(expr, Expression);

	expr->ty = offset->ty;
	expr->op = OP_MUL;
	expr->kids[0] = offset;
	val.i[1] = 0;
	val.i[0] = scale;
	expr->kids[1] = Constant(offset->coord, offset->ty, val);

	return FoldConstant(expr);
}
Ejemplo n.º 24
0
void
OGL_Light::BindIntoBuffer(GLuint _buffer, unsigned int _index)
{
    glBindBuffer(GL_UNIFORM_BUFFER, _buffer);

    GLint baseOffset = m_ComputeLightOffset(_index);
    glBufferSubData(GL_UNIFORM_BUFFER, baseOffset, 3 * sizeof(GLfloat), m_Ia.ToArray().get());
    glBufferSubData(GL_UNIFORM_BUFFER, baseOffset + (4 * sizeof(GLfloat)), 3 * sizeof(GLfloat), m_Id.ToArray().get());
    glBufferSubData(GL_UNIFORM_BUFFER, baseOffset + 2 * (4 * sizeof(GLfloat)), 3 * sizeof(GLfloat), m_Is.ToArray().get());

    baseOffset += 3 * 4 * sizeof(GLfloat);
    switch (m_Type)
    {
    case DIRECTIONAL:
    {
        glBufferSubData(GL_UNIFORM_BUFFER, baseOffset, 3 * sizeof(GLfloat), m_Direction.ToArray().get());
    }
    break;
    case POINT:
    {
        glBufferSubData(GL_UNIFORM_BUFFER, baseOffset, 3 * sizeof(GLfloat), m_Position.ToArray().get());
        baseOffset += 4 * sizeof(GLfloat);
        GLfloat constant = Constant(), linear = Linear(), quadratic = Quadratic();
        glBufferSubData(GL_UNIFORM_BUFFER, baseOffset, sizeof(GLfloat), &constant);
        glBufferSubData(GL_UNIFORM_BUFFER, baseOffset + sizeof(GLfloat), sizeof(GLfloat), &linear);
        glBufferSubData(GL_UNIFORM_BUFFER, baseOffset + 2 * sizeof(GLfloat), sizeof(GLfloat), &quadratic);
    }
    break;
    case SPOT:
    {
        glBufferSubData(GL_UNIFORM_BUFFER, baseOffset, 3 * sizeof(GLfloat), m_Position.ToArray().get());
        glBufferSubData(GL_UNIFORM_BUFFER, baseOffset + (4 * sizeof(GLfloat)), 3 * sizeof(GLfloat), m_Direction.ToArray().get());
        baseOffset += 2 * (4 * sizeof(GLfloat));
        GLfloat innerCutoff = InnerCutoff(), cutoff = Cutoff();
        glBufferSubData(GL_UNIFORM_BUFFER, baseOffset, sizeof(GLfloat), &innerCutoff);
        glBufferSubData(GL_UNIFORM_BUFFER, baseOffset + sizeof(GLfloat), sizeof(GLfloat), &cutoff);
    }
    break;
    default:
        break;
    }

    glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
void InterpreterStubs::generate_interpreter_unwind_activation() {
  comment_section("Interpreter unwind activation");
  entry("interpreter_unwind_activation");

  comment("The exception is the single item on the interpreter stack");

  comment("Unlock and remove the activation");
  unlock_activation(true);

  comment("Remove exception from the stack");
  pop_obj(eax, eax);

  remove_activation(edx);
  get_thread(ecx);
  
  jmp(Constant("shared_code_for_handling_of_exception_forwarding"));

  entry_end(); // interpreter_unwind_activation
}
Ejemplo n.º 26
0
arithmtype Term(void)
{
//if (UnderVerify)
//printf("Term_Expr=%s (%c)\n",Expr, *Expr);
	if (*Expr=='(')
	{
		arithmtype Res;
		Expr++;
//		Res = AddSub();
		Res = Or();
		if (*Expr!=')')
		{
			ErrorDesc = "Missing parenthesis";
			SyntaxError();
		}
		Expr++;
		return Res;
	}
	else if ( (*Expr>='0' && *Expr<='9') || (*Expr=='$') || (*Expr=='-') )
		return Constant();
	else if (*Expr>='A' && *Expr<='Z')
		return Function();
	else if (*Expr=='@')
	{
		return Variable();
	}
	else if (*Expr=='!')
	{
		Expr++;
		return Term()?0:1;
	}
	else
	{
if (UnderVerify)
rtapi_print("TermERROR!_ExprHere=%s\n",Expr);
		ErrorDesc = "Unknown term";
		SyntaxError();
		return 0;
	}
	return 0;
}
Ejemplo n.º 27
0
void Expression::simplify() {
  auto expression_constant_value = getValue();
  std::set<std::string> myNameSet = getNameSet();
  for (auto const& name : myNameSet) {
    simplify(name);
  }
  termList_.erase(std::remove_if(termList_.begin(),
                                 termList_.end(),
                                 [myNameSet](const std::unique_ptr<Term>& term){
                                   for (auto const& name : myNameSet) {
                                     if (term->hasName(name)) {
                                       return false;
                                     }
                                   }
                                   return true;
                                 }),
                  termList_.end());
  if (expression_constant_value) {
    add(Constant(expression_constant_value));
  }
}
Ejemplo n.º 28
0
static AstExpression PlaceBitField(Field fld, AstExpression expr)
{
	AstExpression lsh;
	union value val;

	if (expr->op == OP_CONST)
	{
		expr->val.i[0] <<= fld->pos;
		return expr;
	}

	CREATE_AST_NODE(lsh, Expression);

	lsh->coord = expr->coord;
	lsh->ty = expr->ty;
	lsh->op = OP_LSHIFT;
	lsh->kids[0] = expr;
	val.i[1] = 0;
	val.i[0] = fld->pos;
	lsh->kids[1] = Constant(expr->coord, T(INT), val);

	return lsh;
}
Ejemplo n.º 29
0
 TermFactory::TermFactory() : ConstructionFactory<Term*>("Term") {
     registerConstructor("", fl::null);
     registerConstructor(Bell().className(), &(Bell::constructor));
     registerConstructor(Binary().className(), &(Binary::constructor));
     registerConstructor(Concave().className(), &(Concave::constructor));
     registerConstructor(Constant().className(), &(Constant::constructor));
     registerConstructor(Cosine().className(), &(Cosine::constructor));
     registerConstructor(Discrete().className(), &(Discrete::constructor));
     registerConstructor(Function().className(), &(Function::constructor));
     registerConstructor(Gaussian().className(), &(Gaussian::constructor));
     registerConstructor(GaussianProduct().className(), &(GaussianProduct::constructor));
     registerConstructor(Linear().className(), &(Linear::constructor));
     registerConstructor(PiShape().className(), &(PiShape::constructor));
     registerConstructor(Ramp().className(), &(Ramp::constructor));
     registerConstructor(Rectangle().className(), &(Rectangle::constructor));
     registerConstructor(SShape().className(), &(SShape::constructor));
     registerConstructor(Sigmoid().className(), &(Sigmoid::constructor));
     registerConstructor(SigmoidDifference().className(), &(SigmoidDifference::constructor));
     registerConstructor(SigmoidProduct().className(), &(SigmoidProduct::constructor));
     registerConstructor(Spike().className(), &(Spike::constructor));
     registerConstructor(Trapezoid().className(), &(Trapezoid::constructor));
     registerConstructor(Triangle().className(), &(Triangle::constructor));
     registerConstructor(ZShape().className(), &(ZShape::constructor));
 }
Ejemplo n.º 30
0
void CompilerStubs::generate_compiler_idiv_irem() {
  comment_section("Compiler integer divide and remainder");
  comment("Register eax holds the dividend, register ebx holds the divisor");

  entry("compiler_idiv_irem");
  const int min_int = 0x80000000;
  Label normal_case, special_case;

  Label throw_exception;

  testl(ebx,ebx);
  jcc(equal, Constant(throw_exception));

  // Check for special case
  cmpl(eax, Constant(min_int));
  jcc(not_equal, Constant(normal_case));
  xorl(edx, edx); // Prepare edx for possible special case (where remainder = 0)
  cmpl(ebx, Constant(-1));
  jcc(equal, Constant(special_case));

  // Handle normal case
  bind(normal_case);
  cdql();
  idivl(ebx);

  // Normal and special case exit
  bind(special_case);
  ret();

  bind(throw_exception);
  comment("Throw a DivisionByZeroException");
  leal(eax, Address(Constant("division_by_zero_exception")));
  goto_shared_call_vm(T_VOID);

  entry_end(); // compiler_idiv_irem
}