Commit 37945f73 authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[objects.h splitting] Move Script.

BUG=v8:5402

Change-Id: Ia6639d69a31accf46c10e8d49ea72422225cc8ff
Reviewed-on: https://chromium-review.googlesource.com/517788Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45597}
parent 898eb142
...@@ -710,6 +710,8 @@ action("postmortem-metadata") { ...@@ -710,6 +710,8 @@ action("postmortem-metadata") {
"src/objects-inl.h", "src/objects-inl.h",
"src/objects/map.h", "src/objects/map.h",
"src/objects/map-inl.h", "src/objects/map-inl.h",
"src/objects/script.h",
"src/objects/script-inl.h",
"src/objects/shared-function-info.h", "src/objects/shared-function-info.h",
"src/objects/shared-function-info-inl.h", "src/objects/shared-function-info-inl.h",
] ]
...@@ -1780,6 +1782,8 @@ v8_source_set("v8_base") { ...@@ -1780,6 +1782,8 @@ v8_source_set("v8_base") {
"src/objects/regexp-match-info.h", "src/objects/regexp-match-info.h",
"src/objects/scope-info.cc", "src/objects/scope-info.cc",
"src/objects/scope-info.h", "src/objects/scope-info.h",
"src/objects/script-inl.h",
"src/objects/script.h",
"src/objects/shared-function-info-inl.h", "src/objects/shared-function-info-inl.h",
"src/objects/shared-function-info.h", "src/objects/shared-function-info.h",
"src/objects/string-table.h", "src/objects/string-table.h",
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "src/msan.h" #include "src/msan.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
#include "src/objects/scope-info.h" #include "src/objects/scope-info.h"
#include "src/objects/script-inl.h"
#include "src/string-hasher.h" #include "src/string-hasher.h"
namespace v8 { namespace v8 {
......
...@@ -616,7 +616,6 @@ CAST_ACCESSOR(PropertyCell) ...@@ -616,7 +616,6 @@ CAST_ACCESSOR(PropertyCell)
CAST_ACCESSOR(PrototypeInfo) CAST_ACCESSOR(PrototypeInfo)
CAST_ACCESSOR(RegExpMatchInfo) CAST_ACCESSOR(RegExpMatchInfo)
CAST_ACCESSOR(ScopeInfo) CAST_ACCESSOR(ScopeInfo)
CAST_ACCESSOR(Script)
CAST_ACCESSOR(SeededNumberDictionary) CAST_ACCESSOR(SeededNumberDictionary)
CAST_ACCESSOR(SeqOneByteString) CAST_ACCESSOR(SeqOneByteString)
CAST_ACCESSOR(SeqString) CAST_ACCESSOR(SeqString)
...@@ -5586,54 +5585,6 @@ ACCESSORS(AllocationSite, dependent_code, DependentCode, ...@@ -5586,54 +5585,6 @@ ACCESSORS(AllocationSite, dependent_code, DependentCode,
ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset) ACCESSORS(AllocationSite, weak_next, Object, kWeakNextOffset)
ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset) ACCESSORS(AllocationMemento, allocation_site, Object, kAllocationSiteOffset)
ACCESSORS(Script, source, Object, kSourceOffset)
ACCESSORS(Script, name, Object, kNameOffset)
SMI_ACCESSORS(Script, id, kIdOffset)
SMI_ACCESSORS(Script, line_offset, kLineOffsetOffset)
SMI_ACCESSORS(Script, column_offset, kColumnOffsetOffset)
ACCESSORS(Script, context_data, Object, kContextOffset)
ACCESSORS(Script, wrapper, HeapObject, kWrapperOffset)
SMI_ACCESSORS(Script, type, kTypeOffset)
ACCESSORS(Script, line_ends, Object, kLineEndsOffset)
ACCESSORS_CHECKED(Script, eval_from_shared, Object, kEvalFromSharedOffset,
this->type() != TYPE_WASM)
SMI_ACCESSORS_CHECKED(Script, eval_from_position, kEvalFromPositionOffset,
this->type() != TYPE_WASM)
ACCESSORS(Script, shared_function_infos, FixedArray, kSharedFunctionInfosOffset)
SMI_ACCESSORS(Script, flags, kFlagsOffset)
ACCESSORS(Script, source_url, Object, kSourceUrlOffset)
ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset)
ACCESSORS_CHECKED(Script, wasm_compiled_module, Object, kEvalFromSharedOffset,
this->type() == TYPE_WASM)
ACCESSORS(Script, preparsed_scope_data, PodArray<uint32_t>,
kPreParsedScopeDataOffset)
Script::CompilationType Script::compilation_type() {
return BooleanBit::get(flags(), kCompilationTypeBit) ?
COMPILATION_TYPE_EVAL : COMPILATION_TYPE_HOST;
}
void Script::set_compilation_type(CompilationType type) {
set_flags(BooleanBit::set(flags(), kCompilationTypeBit,
type == COMPILATION_TYPE_EVAL));
}
Script::CompilationState Script::compilation_state() {
return BooleanBit::get(flags(), kCompilationStateBit) ?
COMPILATION_STATE_COMPILED : COMPILATION_STATE_INITIAL;
}
void Script::set_compilation_state(CompilationState state) {
set_flags(BooleanBit::set(flags(), kCompilationStateBit,
state == COMPILATION_STATE_COMPILED));
}
ScriptOriginOptions Script::origin_options() {
return ScriptOriginOptions((flags() & kOriginOptionsMask) >>
kOriginOptionsShift);
}
void Script::set_origin_options(ScriptOriginOptions origin_options) {
DCHECK(!(origin_options.Flags() & ~((1 << kOriginOptionsSize) - 1)));
set_flags((flags() & ~kOriginOptionsMask) |
(origin_options.Flags() << kOriginOptionsShift));
}
SMI_ACCESSORS(StackFrameInfo, line_number, kLineNumberIndex) SMI_ACCESSORS(StackFrameInfo, line_number, kLineNumberIndex)
SMI_ACCESSORS(StackFrameInfo, column_number, kColumnNumberIndex) SMI_ACCESSORS(StackFrameInfo, column_number, kColumnNumberIndex)
SMI_ACCESSORS(StackFrameInfo, script_id, kScriptIdIndex) SMI_ACCESSORS(StackFrameInfo, script_id, kScriptIdIndex)
...@@ -5667,19 +5618,6 @@ BOOL_ACCESSORS(FunctionTemplateInfo, flag, do_not_cache, ...@@ -5667,19 +5618,6 @@ BOOL_ACCESSORS(FunctionTemplateInfo, flag, do_not_cache,
BOOL_ACCESSORS(FunctionTemplateInfo, flag, accept_any_receiver, BOOL_ACCESSORS(FunctionTemplateInfo, flag, accept_any_receiver,
kAcceptAnyReceiver) kAcceptAnyReceiver)
bool Script::HasValidSource() {
Object* src = this->source();
if (!src->IsString()) return true;
String* src_str = String::cast(src);
if (!StringShape(src_str).IsExternal()) return true;
if (src_str->IsOneByteRepresentation()) {
return ExternalOneByteString::cast(src)->resource() != NULL;
} else if (src_str->IsTwoByteRepresentation()) {
return ExternalTwoByteString::cast(src)->resource() != NULL;
}
return true;
}
FeedbackVector* JSFunction::feedback_vector() const { FeedbackVector* JSFunction::feedback_vector() const {
DCHECK(feedback_vector_cell()->value()->IsFeedbackVector()); DCHECK(feedback_vector_cell()->value()->IsFeedbackVector());
return FeedbackVector::cast(feedback_vector_cell()->value()); return FeedbackVector::cast(feedback_vector_cell()->value());
......
...@@ -4637,212 +4637,6 @@ class ContextExtension : public Struct { ...@@ -4637,212 +4637,6 @@ class ContextExtension : public Struct {
DISALLOW_IMPLICIT_CONSTRUCTORS(ContextExtension); DISALLOW_IMPLICIT_CONSTRUCTORS(ContextExtension);
}; };
// Script describes a script which has been added to the VM.
class Script: public Struct {
public:
// Script types.
enum Type {
TYPE_NATIVE = 0,
TYPE_EXTENSION = 1,
TYPE_NORMAL = 2,
TYPE_WASM = 3,
TYPE_INSPECTOR = 4
};
// Script compilation types.
enum CompilationType {
COMPILATION_TYPE_HOST = 0,
COMPILATION_TYPE_EVAL = 1
};
// Script compilation state.
enum CompilationState {
COMPILATION_STATE_INITIAL = 0,
COMPILATION_STATE_COMPILED = 1
};
// [source]: the script source.
DECL_ACCESSORS(source, Object)
// [name]: the script name.
DECL_ACCESSORS(name, Object)
// [id]: the script id.
DECL_INT_ACCESSORS(id)
// [line_offset]: script line offset in resource from where it was extracted.
DECL_INT_ACCESSORS(line_offset)
// [column_offset]: script column offset in resource from where it was
// extracted.
DECL_INT_ACCESSORS(column_offset)
// [context_data]: context data for the context this script was compiled in.
DECL_ACCESSORS(context_data, Object)
// [wrapper]: the wrapper cache. This is either undefined or a WeakCell.
DECL_ACCESSORS(wrapper, HeapObject)
// [type]: the script type.
DECL_INT_ACCESSORS(type)
// [line_ends]: FixedArray of line ends positions.
DECL_ACCESSORS(line_ends, Object)
// [eval_from_shared]: for eval scripts the shared function info for the
// function from which eval was called.
DECL_ACCESSORS(eval_from_shared, Object)
// [eval_from_position]: the source position in the code for the function
// from which eval was called, as positive integer. Or the code offset in the
// code from which eval was called, as negative integer.
DECL_INT_ACCESSORS(eval_from_position)
// [shared_function_infos]: weak fixed array containing all shared
// function infos created from this script.
DECL_ACCESSORS(shared_function_infos, FixedArray)
// [flags]: Holds an exciting bitfield.
DECL_INT_ACCESSORS(flags)
// [source_url]: sourceURL from magic comment
DECL_ACCESSORS(source_url, Object)
// [source_mapping_url]: sourceMappingURL magic comment
DECL_ACCESSORS(source_mapping_url, Object)
// [wasm_compiled_module]: the compiled wasm module this script belongs to.
// This must only be called if the type of this script is TYPE_WASM.
DECL_ACCESSORS(wasm_compiled_module, Object)
DECL_ACCESSORS(preparsed_scope_data, PodArray<uint32_t>)
// [compilation_type]: how the the script was compiled. Encoded in the
// 'flags' field.
inline CompilationType compilation_type();
inline void set_compilation_type(CompilationType type);
// [compilation_state]: determines whether the script has already been
// compiled. Encoded in the 'flags' field.
inline CompilationState compilation_state();
inline void set_compilation_state(CompilationState state);
// [origin_options]: optional attributes set by the embedder via ScriptOrigin,
// and used by the embedder to make decisions about the script. V8 just passes
// this through. Encoded in the 'flags' field.
inline v8::ScriptOriginOptions origin_options();
inline void set_origin_options(ScriptOriginOptions origin_options);
DECLARE_CAST(Script)
// If script source is an external string, check that the underlying
// resource is accessible. Otherwise, always return true.
inline bool HasValidSource();
Object* GetNameOrSourceURL();
// Set eval origin for stack trace formatting.
static void SetEvalOrigin(Handle<Script> script,
Handle<SharedFunctionInfo> outer,
int eval_position);
// Retrieve source position from where eval was called.
int GetEvalPosition();
// Init line_ends array with source code positions of line ends.
static void InitLineEnds(Handle<Script> script);
// Carries information about a source position.
struct PositionInfo {
PositionInfo() : line(-1), column(-1), line_start(-1), line_end(-1) {}
int line; // Zero-based line number.
int column; // Zero-based column number.
int line_start; // Position of first character in line.
int line_end; // Position of final linebreak character in line.
};
// Specifies whether to add offsets to position infos.
enum OffsetFlag { NO_OFFSET = 0, WITH_OFFSET = 1 };
// Retrieves information about the given position, optionally with an offset.
// Returns false on failure, and otherwise writes into the given info object
// on success.
// The static method should is preferable for handlified callsites because it
// initializes the line ends array, avoiding expensive recomputations.
// The non-static version is not allocating and safe for unhandlified
// callsites.
static bool GetPositionInfo(Handle<Script> script, int position,
PositionInfo* info, OffsetFlag offset_flag);
bool GetPositionInfo(int position, PositionInfo* info,
OffsetFlag offset_flag) const;
bool IsUserJavaScript();
// Wrappers for GetPositionInfo
static int GetColumnNumber(Handle<Script> script, int code_offset);
int GetColumnNumber(int code_pos) const;
static int GetLineNumber(Handle<Script> script, int code_offset);
int GetLineNumber(int code_pos) const;
// Get the JS object wrapping the given script; create it if none exists.
static Handle<JSObject> GetWrapper(Handle<Script> script);
// Look through the list of existing shared function infos to find one
// that matches the function literal. Return empty handle if not found.
MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(
Isolate* isolate, const FunctionLiteral* fun);
// Iterate over all script objects on the heap.
class Iterator {
public:
explicit Iterator(Isolate* isolate);
Script* Next();
private:
WeakFixedArray::Iterator iterator_;
DISALLOW_COPY_AND_ASSIGN(Iterator);
};
bool HasPreparsedScopeData() const;
// Dispatched behavior.
DECLARE_PRINTER(Script)
DECLARE_VERIFIER(Script)
static const int kSourceOffset = HeapObject::kHeaderSize;
static const int kNameOffset = kSourceOffset + kPointerSize;
static const int kLineOffsetOffset = kNameOffset + kPointerSize;
static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize;
static const int kContextOffset = kColumnOffsetOffset + kPointerSize;
static const int kWrapperOffset = kContextOffset + kPointerSize;
static const int kTypeOffset = kWrapperOffset + kPointerSize;
static const int kLineEndsOffset = kTypeOffset + kPointerSize;
static const int kIdOffset = kLineEndsOffset + kPointerSize;
static const int kEvalFromSharedOffset = kIdOffset + kPointerSize;
static const int kEvalFromPositionOffset =
kEvalFromSharedOffset + kPointerSize;
static const int kSharedFunctionInfosOffset =
kEvalFromPositionOffset + kPointerSize;
static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize;
static const int kSourceUrlOffset = kFlagsOffset + kPointerSize;
static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize;
static const int kPreParsedScopeDataOffset =
kSourceMappingUrlOffset + kPointerSize;
static const int kSize = kPreParsedScopeDataOffset + kPointerSize;
private:
// Bit positions in the flags field.
static const int kCompilationTypeBit = 0;
static const int kCompilationStateBit = 1;
static const int kOriginOptionsShift = 2;
static const int kOriginOptionsSize = 4;
static const int kOriginOptionsMask = ((1 << kOriginOptionsSize) - 1)
<< kOriginOptionsShift;
DISALLOW_IMPLICIT_CONSTRUCTORS(Script);
};
// List of builtin functions we want to identify to improve code // List of builtin functions we want to identify to improve code
// generation. // generation.
// //
......
// Copyright 2017 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.
#ifndef V8_OBJECTS_SCRIPT_INL_H_
#define V8_OBJECTS_SCRIPT_INL_H_
#include "src/objects/code-cache.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
CAST_ACCESSOR(Script)
ACCESSORS(Script, source, Object, kSourceOffset)
ACCESSORS(Script, name, Object, kNameOffset)
SMI_ACCESSORS(Script, id, kIdOffset)
SMI_ACCESSORS(Script, line_offset, kLineOffsetOffset)
SMI_ACCESSORS(Script, column_offset, kColumnOffsetOffset)
ACCESSORS(Script, context_data, Object, kContextOffset)
ACCESSORS(Script, wrapper, HeapObject, kWrapperOffset)
SMI_ACCESSORS(Script, type, kTypeOffset)
ACCESSORS(Script, line_ends, Object, kLineEndsOffset)
ACCESSORS_CHECKED(Script, eval_from_shared, Object, kEvalFromSharedOffset,
this->type() != TYPE_WASM)
SMI_ACCESSORS_CHECKED(Script, eval_from_position, kEvalFromPositionOffset,
this->type() != TYPE_WASM)
ACCESSORS(Script, shared_function_infos, FixedArray, kSharedFunctionInfosOffset)
SMI_ACCESSORS(Script, flags, kFlagsOffset)
ACCESSORS(Script, source_url, Object, kSourceUrlOffset)
ACCESSORS(Script, source_mapping_url, Object, kSourceMappingUrlOffset)
ACCESSORS_CHECKED(Script, wasm_compiled_module, Object, kEvalFromSharedOffset,
this->type() == TYPE_WASM)
ACCESSORS(Script, preparsed_scope_data, PodArray<uint32_t>,
kPreParsedScopeDataOffset)
Script::CompilationType Script::compilation_type() {
return BooleanBit::get(flags(), kCompilationTypeBit) ? COMPILATION_TYPE_EVAL
: COMPILATION_TYPE_HOST;
}
void Script::set_compilation_type(CompilationType type) {
set_flags(BooleanBit::set(flags(), kCompilationTypeBit,
type == COMPILATION_TYPE_EVAL));
}
Script::CompilationState Script::compilation_state() {
return BooleanBit::get(flags(), kCompilationStateBit)
? COMPILATION_STATE_COMPILED
: COMPILATION_STATE_INITIAL;
}
void Script::set_compilation_state(CompilationState state) {
set_flags(BooleanBit::set(flags(), kCompilationStateBit,
state == COMPILATION_STATE_COMPILED));
}
ScriptOriginOptions Script::origin_options() {
return ScriptOriginOptions((flags() & kOriginOptionsMask) >>
kOriginOptionsShift);
}
void Script::set_origin_options(ScriptOriginOptions origin_options) {
DCHECK(!(origin_options.Flags() & ~((1 << kOriginOptionsSize) - 1)));
set_flags((flags() & ~kOriginOptionsMask) |
(origin_options.Flags() << kOriginOptionsShift));
}
bool Script::HasValidSource() {
Object* src = this->source();
if (!src->IsString()) return true;
String* src_str = String::cast(src);
if (!StringShape(src_str).IsExternal()) return true;
if (src_str->IsOneByteRepresentation()) {
return ExternalOneByteString::cast(src)->resource() != NULL;
} else if (src_str->IsTwoByteRepresentation()) {
return ExternalTwoByteString::cast(src)->resource() != NULL;
}
return true;
}
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_SCRIPT_INL_H_
// Copyright 2017 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.
#ifndef V8_OBJECTS_SCRIPT_H_
#define V8_OBJECTS_SCRIPT_H_
#include "src/objects.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
// Script describes a script which has been added to the VM.
class Script : public Struct {
public:
// Script types.
enum Type {
TYPE_NATIVE = 0,
TYPE_EXTENSION = 1,
TYPE_NORMAL = 2,
TYPE_WASM = 3,
TYPE_INSPECTOR = 4
};
// Script compilation types.
enum CompilationType { COMPILATION_TYPE_HOST = 0, COMPILATION_TYPE_EVAL = 1 };
// Script compilation state.
enum CompilationState {
COMPILATION_STATE_INITIAL = 0,
COMPILATION_STATE_COMPILED = 1
};
// [source]: the script source.
DECL_ACCESSORS(source, Object)
// [name]: the script name.
DECL_ACCESSORS(name, Object)
// [id]: the script id.
DECL_INT_ACCESSORS(id)
// [line_offset]: script line offset in resource from where it was extracted.
DECL_INT_ACCESSORS(line_offset)
// [column_offset]: script column offset in resource from where it was
// extracted.
DECL_INT_ACCESSORS(column_offset)
// [context_data]: context data for the context this script was compiled in.
DECL_ACCESSORS(context_data, Object)
// [wrapper]: the wrapper cache. This is either undefined or a WeakCell.
DECL_ACCESSORS(wrapper, HeapObject)
// [type]: the script type.
DECL_INT_ACCESSORS(type)
// [line_ends]: FixedArray of line ends positions.
DECL_ACCESSORS(line_ends, Object)
// [eval_from_shared]: for eval scripts the shared function info for the
// function from which eval was called.
DECL_ACCESSORS(eval_from_shared, Object)
// [eval_from_position]: the source position in the code for the function
// from which eval was called, as positive integer. Or the code offset in the
// code from which eval was called, as negative integer.
DECL_INT_ACCESSORS(eval_from_position)
// [shared_function_infos]: weak fixed array containing all shared
// function infos created from this script.
DECL_ACCESSORS(shared_function_infos, FixedArray)
// [flags]: Holds an exciting bitfield.
DECL_INT_ACCESSORS(flags)
// [source_url]: sourceURL from magic comment
DECL_ACCESSORS(source_url, Object)
// [source_mapping_url]: sourceMappingURL magic comment
DECL_ACCESSORS(source_mapping_url, Object)
// [wasm_compiled_module]: the compiled wasm module this script belongs to.
// This must only be called if the type of this script is TYPE_WASM.
DECL_ACCESSORS(wasm_compiled_module, Object)
DECL_ACCESSORS(preparsed_scope_data, PodArray<uint32_t>)
// [compilation_type]: how the the script was compiled. Encoded in the
// 'flags' field.
inline CompilationType compilation_type();
inline void set_compilation_type(CompilationType type);
// [compilation_state]: determines whether the script has already been
// compiled. Encoded in the 'flags' field.
inline CompilationState compilation_state();
inline void set_compilation_state(CompilationState state);
// [origin_options]: optional attributes set by the embedder via ScriptOrigin,
// and used by the embedder to make decisions about the script. V8 just passes
// this through. Encoded in the 'flags' field.
inline v8::ScriptOriginOptions origin_options();
inline void set_origin_options(ScriptOriginOptions origin_options);
DECLARE_CAST(Script)
// If script source is an external string, check that the underlying
// resource is accessible. Otherwise, always return true.
inline bool HasValidSource();
Object* GetNameOrSourceURL();
// Set eval origin for stack trace formatting.
static void SetEvalOrigin(Handle<Script> script,
Handle<SharedFunctionInfo> outer,
int eval_position);
// Retrieve source position from where eval was called.
int GetEvalPosition();
// Init line_ends array with source code positions of line ends.
static void InitLineEnds(Handle<Script> script);
// Carries information about a source position.
struct PositionInfo {
PositionInfo() : line(-1), column(-1), line_start(-1), line_end(-1) {}
int line; // Zero-based line number.
int column; // Zero-based column number.
int line_start; // Position of first character in line.
int line_end; // Position of final linebreak character in line.
};
// Specifies whether to add offsets to position infos.
enum OffsetFlag { NO_OFFSET = 0, WITH_OFFSET = 1 };
// Retrieves information about the given position, optionally with an offset.
// Returns false on failure, and otherwise writes into the given info object
// on success.
// The static method should is preferable for handlified callsites because it
// initializes the line ends array, avoiding expensive recomputations.
// The non-static version is not allocating and safe for unhandlified
// callsites.
static bool GetPositionInfo(Handle<Script> script, int position,
PositionInfo* info, OffsetFlag offset_flag);
bool GetPositionInfo(int position, PositionInfo* info,
OffsetFlag offset_flag) const;
bool IsUserJavaScript();
// Wrappers for GetPositionInfo
static int GetColumnNumber(Handle<Script> script, int code_offset);
int GetColumnNumber(int code_pos) const;
static int GetLineNumber(Handle<Script> script, int code_offset);
int GetLineNumber(int code_pos) const;
// Get the JS object wrapping the given script; create it if none exists.
static Handle<JSObject> GetWrapper(Handle<Script> script);
// Look through the list of existing shared function infos to find one
// that matches the function literal. Return empty handle if not found.
MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(
Isolate* isolate, const FunctionLiteral* fun);
// Iterate over all script objects on the heap.
class Iterator {
public:
explicit Iterator(Isolate* isolate);
Script* Next();
private:
WeakFixedArray::Iterator iterator_;
DISALLOW_COPY_AND_ASSIGN(Iterator);
};
bool HasPreparsedScopeData() const;
// Dispatched behavior.
DECLARE_PRINTER(Script)
DECLARE_VERIFIER(Script)
static const int kSourceOffset = HeapObject::kHeaderSize;
static const int kNameOffset = kSourceOffset + kPointerSize;
static const int kLineOffsetOffset = kNameOffset + kPointerSize;
static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize;
static const int kContextOffset = kColumnOffsetOffset + kPointerSize;
static const int kWrapperOffset = kContextOffset + kPointerSize;
static const int kTypeOffset = kWrapperOffset + kPointerSize;
static const int kLineEndsOffset = kTypeOffset + kPointerSize;
static const int kIdOffset = kLineEndsOffset + kPointerSize;
static const int kEvalFromSharedOffset = kIdOffset + kPointerSize;
static const int kEvalFromPositionOffset =
kEvalFromSharedOffset + kPointerSize;
static const int kSharedFunctionInfosOffset =
kEvalFromPositionOffset + kPointerSize;
static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize;
static const int kSourceUrlOffset = kFlagsOffset + kPointerSize;
static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize;
static const int kPreParsedScopeDataOffset =
kSourceMappingUrlOffset + kPointerSize;
static const int kSize = kPreParsedScopeDataOffset + kPointerSize;
private:
// Bit positions in the flags field.
static const int kCompilationTypeBit = 0;
static const int kCompilationStateBit = 1;
static const int kOriginOptionsShift = 2;
static const int kOriginOptionsSize = 4;
static const int kOriginOptionsMask = ((1 << kOriginOptionsSize) - 1)
<< kOriginOptionsShift;
DISALLOW_IMPLICIT_CONSTRUCTORS(Script);
};
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_SCRIPT_H_
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define V8_OBJECTS_SHARED_FUNCTION_INFO_H_ #define V8_OBJECTS_SHARED_FUNCTION_INFO_H_
#include "src/objects.h" #include "src/objects.h"
#include "src/objects/script.h"
// Has to be the last include (doesn't have include guards): // Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h" #include "src/objects/object-macros.h"
......
...@@ -1247,6 +1247,8 @@ ...@@ -1247,6 +1247,8 @@
'objects/regexp-match-info.h', 'objects/regexp-match-info.h',
'objects/scope-info.cc', 'objects/scope-info.cc',
'objects/scope-info.h', 'objects/scope-info.h',
'objects/script.h',
'objects/script-inl.h',
'objects/shared-function-info-inl.h', 'objects/shared-function-info-inl.h',
'objects/shared-function-info.h', 'objects/shared-function-info.h',
'objects/string-table.h', 'objects/string-table.h',
...@@ -2556,6 +2558,8 @@ ...@@ -2556,6 +2558,8 @@
'objects-inl.h', 'objects-inl.h',
'objects/map.h', 'objects/map.h',
'objects/map-inl.h', 'objects/map-inl.h',
'objects/script.h',
'objects/script-inl.h',
'objects/shared-function-info.h', 'objects/shared-function-info.h',
'objects/shared-function-info-inl.h', 'objects/shared-function-info-inl.h',
], ],
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "src/debug/debug.h" #include "src/debug/debug.h"
#include "src/debug/interface-types.h" #include "src/debug/interface-types.h"
#include "src/objects.h" #include "src/objects.h"
#include "src/objects/script.h"
#include "src/trap-handler/trap-handler.h" #include "src/trap-handler/trap-handler.h"
#include "src/wasm/wasm-limits.h" #include "src/wasm/wasm-limits.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment