local-isolate.cc 1.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/execution/local-isolate.h"

#include "src/execution/isolate.h"
#include "src/execution/thread-id.h"
#include "src/handles/handles-inl.h"
#include "src/logging/local-logger.h"

namespace v8 {
namespace internal {

15
LocalIsolate::LocalIsolate(Isolate* isolate, ThreadKind kind)
16
    : HiddenLocalFactory(isolate),
17
      heap_(isolate->heap(), kind),
18
      isolate_(isolate),
19
      logger_(new LocalLogger(isolate)),
20 21 22
      thread_id_(ThreadId::Current()),
      stack_limit_(kind == ThreadKind::kMain
                       ? isolate->stack_guard()->real_climit()
23 24
                       : GetCurrentStackPosition() - FLAG_stack_size * KB),
      supported_import_assertions_(isolate->supported_import_assertions()) {}
25 26 27 28 29 30 31 32 33 34 35

LocalIsolate::~LocalIsolate() = default;

int LocalIsolate::GetNextScriptId() { return isolate_->GetNextScriptId(); }

#if V8_SFI_HAS_UNIQUE_ID
int LocalIsolate::GetNextUniqueSharedFunctionInfoId() {
  return isolate_->GetNextUniqueSharedFunctionInfoId();
}
#endif  // V8_SFI_HAS_UNIQUE_ID

36
bool LocalIsolate::is_collecting_type_profile() const {
37 38 39 40
  // TODO(leszeks): Figure out if it makes sense to check this asynchronously.
  return isolate_->is_collecting_type_profile();
}

41 42
// static
bool StackLimitCheck::HasOverflowed(LocalIsolate* local_isolate) {
43
  return GetCurrentStackPosition() < local_isolate->stack_limit();
44 45
}

46 47
}  // namespace internal
}  // namespace v8