1

クラスは次のv8::ResourceConstraintsように定義されます。

class V8EXPORT ResourceConstraints {
 public:
  ResourceConstraints();
  int max_young_space_size() const { return max_young_space_size_; }
  void set_max_young_space_size(int value) { max_young_space_size_ = value; }
  int max_old_space_size() const { return max_old_space_size_; }
  void set_max_old_space_size(int value) { max_old_space_size_ = value; }
  int max_executable_size() { return max_executable_size_; }
  void set_max_executable_size(int value) { max_executable_size_ = value; }
  uint32_t* stack_limit() const { return stack_limit_; }
  // Sets an address beyond which the VM's stack may not grow.
  void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
 private:
  int max_young_space_size_;
  int max_old_space_size_;
  int max_executable_size_;
  uint32_t* stack_limit_;
};

誰かが、、、そして何young_space_sizeであるかを教えてもらえますか?それらのユニットは何ですか、それらはどのように関連していますか?ドキュメントはあまりないようです。old_space_sizemax_executable_size

また、どのようにstack_limitプロパティを使用しますか?たとえば、V8アイソレートが1MB以下のスタックスペースを使用するようにしたい場合、どのようにポインター値を計算しますstack_limitか?

4

1 に答える 1

1

v8 / test / cctest / test-api.ccは、この関数を使用して制限を計算します。

// Uses the address of a local variable to determine the stack top now.
// Given a size, returns an address that is that far from the current
// top of stack.
static uint32_t* ComputeStackLimit(uint32_t size) {
  uint32_t* answer = &size - (size / sizeof(size));
  // If the size is very large and the stack is very near the bottom of
  // memory then the calculation above may wrap around and give an address
  // that is above the (downwards-growing) stack.  In that case we return
  // a very low address.
  if (answer > &size) return reinterpret_cast<uint32_t*>(sizeof(size));
  return answer;
}
于 2014-01-03T00:44:17.967 に答える