Upgrade to Pro — share decks privately, control downloads, hide ads and more …

torque in V8

torque in V8

V8 javascript eingineのdslであるtorqueの話

More Decks by Taketoshi Aono(青野健利 a.k.a brn)

Other Decks in Programming

Transcript

  1. function add100() {! let value = 0;! for (let i

    = 0; i < 100; i++) {! value += 1;! }! return value;! }!
  2. TNode<IntPtrT> Add100(TNode<Context> context) {! TVARIABLE(var_value, MachineType::PointerRepresentation(), IntPtrConstant(0));! TVARIABLE(var_index, MachineType::PointerRepresentation(), IntPtrConstant(0));!

    ! Label loop(this), after_loop(this);! ! Branch(IntPtrGreaterThan(IntPtrConstant(100), var_index), &loop, &after_loop);! BIND(&loop);! {! var_a.Bind(IntPtrAdd(var_a, IntPtrConstant(1)));! Increment(&var_index, 1);! Branch(IntPtrGreaterThan(IntPtrConstant(100), var_index),! &loop, &after_loop);! }! BIND(&after_loop);! return var_value.value;! }!
  3. macro Add100(): Smi {! let value: Smi = 0;! let

    len: Smi = 100;! ! for (let i: Smi = 0; k < len; i = i + 1) {! value = value + 1;! }! return value;! }!
  4. extern macro Print(Object);! ! extern builtin ToObject(Context, Number): Object;! !

    extern runtime CreateDataProperty(! Context, Object, String, Object);!