v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
local-factory.cc
Go to the documentation of this file.
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
13#include "src/logging/log.h"
17#include "src/objects/string.h"
18#include "src/roots/roots-inl.h"
20
21namespace v8 {
22namespace internal {
23
24LocalFactory::LocalFactory(Isolate* isolate) : roots_(isolate) {}
25
27 ScriptEventType script_event_type) {
28 // TODO(leszeks): Actually add the script to the main Isolate's script list,
29 // in a thread-safe way.
30 //
31 // At the moment, we have to do one final fix-up during off-thread
32 // finalization, where we add the created script to the script list, but this
33 // relies on there being exactly one script created during the lifetime of
34 // this LocalFactory.
35 //
36 // For now, prevent accidentally creating more scripts that don't get added to
37 // the script list with a simple DCHECK.
38 int script_id = script->id();
39#ifdef DEBUG
40 if (script_id != Script::kTemporaryScriptId) {
41 DCHECK(!a_script_was_added_to_the_script_list_);
42 a_script_was_added_to_the_script_list_ = true;
43 }
44#endif
45 LOG(isolate(), ScriptEvent(script_event_type, script_id));
46}
47
49 AllocationType allocation,
50 AllocationAlignment alignment) {
51 DCHECK(allocation == AllocationType::kOld ||
52 allocation == AllocationType::kSharedOld ||
53 allocation == AllocationType::kTrusted);
54 return HeapObject::FromAddress(isolate()->heap()->AllocateRawOrFail(
55 size, allocation, AllocationOrigin::kRuntime, alignment));
56}
57
59
61
64
68
69} // namespace internal
70} // namespace v8
static Tagged< HeapObject > FromAddress(Address address)
Handle< Object > NumberToStringCacheGet(Tagged< Object > number, int hash)
LocalFactory(Isolate *isolate)
int NumberToStringCacheHash(Tagged< Smi > number)
void NumberToStringCacheSet(DirectHandle< Object > number, int hash, DirectHandle< String > js_string)
void ProcessNewScript(DirectHandle< Script > script, ScriptEventType script_event_type)
Tagged< HeapObject > AllocateRaw(int size, AllocationType allocation, AllocationAlignment alignment=kTaggedAligned)
static constexpr int kTemporaryScriptId
Definition script.h:42
#define LOG(isolate, Call)
Definition log.h:78
#define DCHECK(condition)
Definition logging.h:482