jitcraft/Code.h
changeset 47 050939c6181e
parent 44 c920f9328716
child 53 13bd3a8df334
     1.1 --- a/jitcraft/Code.h	Tue Jul 03 13:53:34 2012 -0400
     1.2 +++ b/jitcraft/Code.h	Wed Jul 04 19:39:00 2012 -0400
     1.3 @@ -1,4 +1,5 @@
     1.4 -/*
     1.5 +/* vim: set ts=4 sw=4 tw=99 et:
     1.6 + *
     1.7   * Copyright (C) 2012 David Anderson
     1.8   *
     1.9   * This file is part of JITCraft.
    1.10 @@ -38,11 +39,18 @@
    1.11      Barriered<ByteArray> bytecode_;
    1.12      Barriered<FixedArray> locals_;
    1.13      Barriered<FixedArray> objects_;
    1.14 +    Barriered<ByteArray> safepoints_;
    1.15      unsigned maxStackDepth_;
    1.16  
    1.17    public:
    1.18 +    static inline size_t BytesPerSafepoint(size_t stackDepth) {
    1.19 +        return (Align(stackDepth, 8) / 8) + sizeof(unsigned);
    1.20 +    }
    1.21 +
    1.22 +  public:
    1.23      static Code *New(Zone *zone, Handle<ByteArray> bytecode, Handle<FixedArray> locals,
    1.24 -                     Handle<FixedArray> objects, unsigned maxStackDepth, Handle<Module> module);
    1.25 +                     Handle<FixedArray> objects, unsigned maxStackDepth, Handle<Module> module,
    1.26 +                     Handle<ByteArray> safepoints);
    1.27  
    1.28      Module *module() {
    1.29          return module_;
    1.30 @@ -68,6 +76,15 @@
    1.31      Object *object(size_t index) {
    1.32          return objects_->at(index);
    1.33      }
    1.34 +    ByteArray *safepoints() {
    1.35 +        return safepoints_;
    1.36 +    }
    1.37 +    uint8 *safepointAt(unsigned pcOffset);
    1.38 +
    1.39 +    unsigned pcToOffset(bytecode *pc) {
    1.40 +        assert(pc >= start() && pc < start() + length());
    1.41 +        return pc - start();
    1.42 +    }
    1.43  
    1.44      // GC Descriptor.
    1.45      static inline size_t offsetOfModule() {