mirror of https://github.com/lukechilds/node.git
Browse Source
Pick up V8 4.8 branch-head. This branch brings in @@isConcatSpreadable, @@toPrimitive and ToLength ES6 changes. For full details see: http://v8project.blogspot.de/2015/11/v8-release-48.html https://github.com/v8/v8/commit/fa163e2 Ref: https://github.com/nodejs/node/pull/4399 PR-URL: https://github.com/nodejs/node/pull/4785 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>process-exit-stdio-flushing
1316 changed files with 64257 additions and 31913 deletions
File diff suppressed because it is too large
@ -0,0 +1,77 @@ |
|||||
|
# Copyright 2015 the V8 project authors. All rights reserved. |
||||
|
# Copyright 2015 The Chromium Authors. All rights reserved. |
||||
|
# Use of this source code is governed by a BSD-style license that can be |
||||
|
# found in the LICENSE file. |
||||
|
{ |
||||
|
'conditions': [ |
||||
|
# Copy the VS runtime DLLs into the isolate so that they |
||||
|
# don't have to be preinstalled on the target machine. |
||||
|
# |
||||
|
# VS2013 runtimes |
||||
|
['OS=="win" and msvs_version==2013 and component=="shared_library" and CONFIGURATION_NAME=="Debug"', { |
||||
|
'variables': { |
||||
|
'files': [ |
||||
|
'<(PRODUCT_DIR)/x64/msvcp120d.dll', |
||||
|
'<(PRODUCT_DIR)/x64/msvcr120d.dll', |
||||
|
], |
||||
|
}, |
||||
|
}], |
||||
|
['OS=="win" and msvs_version==2013 and component=="shared_library" and CONFIGURATION_NAME=="Release"', { |
||||
|
'variables': { |
||||
|
'files': [ |
||||
|
'<(PRODUCT_DIR)/x64/msvcp120.dll', |
||||
|
'<(PRODUCT_DIR)/x64/msvcr120.dll', |
||||
|
], |
||||
|
}, |
||||
|
}], |
||||
|
['OS=="win" and msvs_version==2013 and component=="shared_library" and (CONFIGURATION_NAME=="Debug" or CONFIGURATION_NAME=="Debug_x64")', { |
||||
|
'variables': { |
||||
|
'files': [ |
||||
|
'<(PRODUCT_DIR)/msvcp120d.dll', |
||||
|
'<(PRODUCT_DIR)/msvcr120d.dll', |
||||
|
], |
||||
|
}, |
||||
|
}], |
||||
|
['OS=="win" and msvs_version==2013 and component=="shared_library" and (CONFIGURATION_NAME=="Release" or CONFIGURATION_NAME=="Release_x64")', { |
||||
|
'variables': { |
||||
|
'files': [ |
||||
|
'<(PRODUCT_DIR)/msvcp120.dll', |
||||
|
'<(PRODUCT_DIR)/msvcr120.dll', |
||||
|
], |
||||
|
}, |
||||
|
}], |
||||
|
# VS2015 runtimes |
||||
|
['OS=="win" and msvs_version==2015 and component=="shared_library" and CONFIGURATION_NAME=="Debug"', { |
||||
|
'variables': { |
||||
|
'files': [ |
||||
|
'<(PRODUCT_DIR)/x64/msvcp140d.dll', |
||||
|
'<(PRODUCT_DIR)/x64/vccorlib140d.dll', |
||||
|
], |
||||
|
}, |
||||
|
}], |
||||
|
['OS=="win" and msvs_version==2015 and component=="shared_library" and CONFIGURATION_NAME=="Release"', { |
||||
|
'variables': { |
||||
|
'files': [ |
||||
|
'<(PRODUCT_DIR)/x64/msvcp140.dll', |
||||
|
'<(PRODUCT_DIR)/x64/vccorlib140.dll', |
||||
|
], |
||||
|
}, |
||||
|
}], |
||||
|
['OS=="win" and msvs_version==2015 and component=="shared_library" and (CONFIGURATION_NAME=="Debug" or CONFIGURATION_NAME=="Debug_x64")', { |
||||
|
'variables': { |
||||
|
'files': [ |
||||
|
'<(PRODUCT_DIR)/msvcp140d.dll', |
||||
|
'<(PRODUCT_DIR)/vccorlib140d.dll', |
||||
|
], |
||||
|
}, |
||||
|
}], |
||||
|
['OS=="win" and msvs_version==2015 and component=="shared_library" and (CONFIGURATION_NAME=="Release" or CONFIGURATION_NAME=="Release_x64")', { |
||||
|
'variables': { |
||||
|
'files': [ |
||||
|
'<(PRODUCT_DIR)/msvcp140.dll', |
||||
|
'<(PRODUCT_DIR)/vccorlib140.dll', |
||||
|
], |
||||
|
}, |
||||
|
}], |
||||
|
], |
||||
|
} |
@ -0,0 +1,268 @@ |
|||||
|
#!/usr/bin/env python |
||||
|
# Copyright 2015 the V8 project authors. All rights reserved. |
||||
|
# Copyright 2014 The Chromium Authors. All rights reserved. |
||||
|
# Use of this source code is governed by a BSD-style license that can be |
||||
|
# found in the LICENSE file. |
||||
|
|
||||
|
import json |
||||
|
import os |
||||
|
import pipes |
||||
|
import shutil |
||||
|
import subprocess |
||||
|
import sys |
||||
|
import vs_toolchain |
||||
|
|
||||
|
|
||||
|
script_dir = os.path.dirname(os.path.realpath(__file__)) |
||||
|
chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir)) |
||||
|
SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
||||
|
sys.path.insert(1, os.path.join(chrome_src, 'tools')) |
||||
|
sys.path.insert(0, os.path.join(chrome_src, 'build', 'gyp', 'pylib')) |
||||
|
json_data_file = os.path.join(script_dir, 'win_toolchain.json') |
||||
|
|
||||
|
|
||||
|
import gyp |
||||
|
|
||||
|
|
||||
|
def SetEnvironmentAndGetRuntimeDllDirs(): |
||||
|
"""Sets up os.environ to use the depot_tools VS toolchain with gyp, and |
||||
|
returns the location of the VS runtime DLLs so they can be copied into |
||||
|
the output directory after gyp generation. |
||||
|
""" |
||||
|
vs2013_runtime_dll_dirs = None |
||||
|
depot_tools_win_toolchain = \ |
||||
|
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) |
||||
|
# When running on a non-Windows host, only do this if the SDK has explicitly |
||||
|
# been downloaded before (in which case json_data_file will exist). |
||||
|
if ((sys.platform in ('win32', 'cygwin') or os.path.exists(json_data_file)) |
||||
|
and depot_tools_win_toolchain): |
||||
|
if not os.path.exists(json_data_file): |
||||
|
Update() |
||||
|
with open(json_data_file, 'r') as tempf: |
||||
|
toolchain_data = json.load(tempf) |
||||
|
|
||||
|
toolchain = toolchain_data['path'] |
||||
|
version = toolchain_data['version'] |
||||
|
win_sdk = toolchain_data.get('win_sdk') |
||||
|
if not win_sdk: |
||||
|
win_sdk = toolchain_data['win8sdk'] |
||||
|
wdk = toolchain_data['wdk'] |
||||
|
# TODO(scottmg): The order unfortunately matters in these. They should be |
||||
|
# split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call |
||||
|
# below). http://crbug.com/345992 |
||||
|
vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs'] |
||||
|
|
||||
|
os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain |
||||
|
os.environ['GYP_MSVS_VERSION'] = version |
||||
|
# We need to make sure windows_sdk_path is set to the automated |
||||
|
# toolchain values in GYP_DEFINES, but don't want to override any |
||||
|
# otheroptions.express |
||||
|
# values there. |
||||
|
gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES')) |
||||
|
gyp_defines_dict['windows_sdk_path'] = win_sdk |
||||
|
os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v))) |
||||
|
for k, v in gyp_defines_dict.iteritems()) |
||||
|
os.environ['WINDOWSSDKDIR'] = win_sdk |
||||
|
os.environ['WDK_DIR'] = wdk |
||||
|
# Include the VS runtime in the PATH in case it's not machine-installed. |
||||
|
runtime_path = ';'.join(vs2013_runtime_dll_dirs) |
||||
|
os.environ['PATH'] = runtime_path + ';' + os.environ['PATH'] |
||||
|
return vs2013_runtime_dll_dirs |
||||
|
|
||||
|
|
||||
|
def _VersionNumber(): |
||||
|
"""Gets the standard version number ('120', '140', etc.) based on |
||||
|
GYP_MSVS_VERSION.""" |
||||
|
if os.environ['GYP_MSVS_VERSION'] == '2013': |
||||
|
return '120' |
||||
|
elif os.environ['GYP_MSVS_VERSION'] == '2015': |
||||
|
return '140' |
||||
|
else: |
||||
|
raise ValueError('Unexpected GYP_MSVS_VERSION') |
||||
|
|
||||
|
|
||||
|
def _CopyRuntimeImpl(target, source): |
||||
|
"""Copy |source| to |target| if it doesn't already exist or if it |
||||
|
needs to be updated. |
||||
|
""" |
||||
|
if (os.path.isdir(os.path.dirname(target)) and |
||||
|
(not os.path.isfile(target) or |
||||
|
os.stat(target).st_mtime != os.stat(source).st_mtime)): |
||||
|
print 'Copying %s to %s...' % (source, target) |
||||
|
if os.path.exists(target): |
||||
|
os.unlink(target) |
||||
|
shutil.copy2(source, target) |
||||
|
|
||||
|
|
||||
|
def _CopyRuntime2013(target_dir, source_dir, dll_pattern): |
||||
|
"""Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't |
||||
|
exist, but the target directory does exist.""" |
||||
|
for file_part in ('p', 'r'): |
||||
|
dll = dll_pattern % file_part |
||||
|
target = os.path.join(target_dir, dll) |
||||
|
source = os.path.join(source_dir, dll) |
||||
|
_CopyRuntimeImpl(target, source) |
||||
|
|
||||
|
|
||||
|
def _CopyRuntime2015(target_dir, source_dir, dll_pattern): |
||||
|
"""Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't |
||||
|
exist, but the target directory does exist.""" |
||||
|
for file_part in ('msvcp', 'vccorlib'): |
||||
|
dll = dll_pattern % file_part |
||||
|
target = os.path.join(target_dir, dll) |
||||
|
source = os.path.join(source_dir, dll) |
||||
|
_CopyRuntimeImpl(target, source) |
||||
|
|
||||
|
|
||||
|
def CopyVsRuntimeDlls(output_dir, runtime_dirs): |
||||
|
"""Copies the VS runtime DLLs from the given |runtime_dirs| to the output |
||||
|
directory so that even if not system-installed, built binaries are likely to |
||||
|
be able to run. |
||||
|
|
||||
|
This needs to be run after gyp has been run so that the expected target |
||||
|
output directories are already created. |
||||
|
""" |
||||
|
x86, x64 = runtime_dirs |
||||
|
out_debug = os.path.join(output_dir, 'Debug') |
||||
|
out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64') |
||||
|
out_release = os.path.join(output_dir, 'Release') |
||||
|
out_release_nacl64 = os.path.join(output_dir, 'Release', 'x64') |
||||
|
out_debug_x64 = os.path.join(output_dir, 'Debug_x64') |
||||
|
out_release_x64 = os.path.join(output_dir, 'Release_x64') |
||||
|
|
||||
|
if os.path.exists(out_debug) and not os.path.exists(out_debug_nacl64): |
||||
|
os.makedirs(out_debug_nacl64) |
||||
|
if os.path.exists(out_release) and not os.path.exists(out_release_nacl64): |
||||
|
os.makedirs(out_release_nacl64) |
||||
|
if os.environ.get('GYP_MSVS_VERSION') == '2015': |
||||
|
_CopyRuntime2015(out_debug, x86, '%s140d.dll') |
||||
|
_CopyRuntime2015(out_release, x86, '%s140.dll') |
||||
|
_CopyRuntime2015(out_debug_x64, x64, '%s140d.dll') |
||||
|
_CopyRuntime2015(out_release_x64, x64, '%s140.dll') |
||||
|
_CopyRuntime2015(out_debug_nacl64, x64, '%s140d.dll') |
||||
|
_CopyRuntime2015(out_release_nacl64, x64, '%s140.dll') |
||||
|
else: |
||||
|
# VS2013 is the default. |
||||
|
_CopyRuntime2013(out_debug, x86, 'msvc%s120d.dll') |
||||
|
_CopyRuntime2013(out_release, x86, 'msvc%s120.dll') |
||||
|
_CopyRuntime2013(out_debug_x64, x64, 'msvc%s120d.dll') |
||||
|
_CopyRuntime2013(out_release_x64, x64, 'msvc%s120.dll') |
||||
|
_CopyRuntime2013(out_debug_nacl64, x64, 'msvc%s120d.dll') |
||||
|
_CopyRuntime2013(out_release_nacl64, x64, 'msvc%s120.dll') |
||||
|
|
||||
|
# Copy the PGO runtime library to the release directories. |
||||
|
if os.environ.get('GYP_MSVS_OVERRIDE_PATH'): |
||||
|
pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'), |
||||
|
'VC', 'bin') |
||||
|
pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64') |
||||
|
pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll' |
||||
|
source_x86 = os.path.join(pgo_x86_runtime_dir, pgo_runtime_dll) |
||||
|
if os.path.exists(source_x86): |
||||
|
_CopyRuntimeImpl(os.path.join(out_release, pgo_runtime_dll), source_x86) |
||||
|
source_x64 = os.path.join(pgo_x64_runtime_dir, pgo_runtime_dll) |
||||
|
if os.path.exists(source_x64): |
||||
|
_CopyRuntimeImpl(os.path.join(out_release_x64, pgo_runtime_dll), |
||||
|
source_x64) |
||||
|
|
||||
|
|
||||
|
def CopyDlls(target_dir, configuration, target_cpu): |
||||
|
"""Copy the VS runtime DLLs into the requested directory as needed. |
||||
|
|
||||
|
configuration is one of 'Debug' or 'Release'. |
||||
|
target_cpu is one of 'x86' or 'x64'. |
||||
|
|
||||
|
The debug configuration gets both the debug and release DLLs; the |
||||
|
release config only the latter. |
||||
|
""" |
||||
|
vs2013_runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs() |
||||
|
if not vs2013_runtime_dll_dirs: |
||||
|
return |
||||
|
|
||||
|
x64_runtime, x86_runtime = vs2013_runtime_dll_dirs |
||||
|
runtime_dir = x64_runtime if target_cpu == 'x64' else x86_runtime |
||||
|
_CopyRuntime2013( |
||||
|
target_dir, runtime_dir, 'msvc%s' + _VersionNumber() + '.dll') |
||||
|
if configuration == 'Debug': |
||||
|
_CopyRuntime2013( |
||||
|
target_dir, runtime_dir, 'msvc%s' + _VersionNumber() + 'd.dll') |
||||
|
|
||||
|
|
||||
|
def _GetDesiredVsToolchainHashes(): |
||||
|
"""Load a list of SHA1s corresponding to the toolchains that we want installed |
||||
|
to build with.""" |
||||
|
if os.environ.get('GYP_MSVS_VERSION') == '2015': |
||||
|
return ['49ae4b60d898182fc3f521c2fcda82c453915011'] |
||||
|
else: |
||||
|
# Default to VS2013. |
||||
|
return ['ee7d718ec60c2dc5d255bbe325909c2021a7efef'] |
||||
|
|
||||
|
|
||||
|
def Update(force=False): |
||||
|
"""Requests an update of the toolchain to the specific hashes we have at |
||||
|
this revision. The update outputs a .json of the various configuration |
||||
|
information required to pass to gyp which we use in |GetToolchainDir()|. |
||||
|
""" |
||||
|
if force != False and force != '--force': |
||||
|
print >>sys.stderr, 'Unknown parameter "%s"' % force |
||||
|
return 1 |
||||
|
if force == '--force' or os.path.exists(json_data_file): |
||||
|
force = True |
||||
|
|
||||
|
depot_tools_win_toolchain = \ |
||||
|
bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1'))) |
||||
|
if ((sys.platform in ('win32', 'cygwin') or force) and |
||||
|
depot_tools_win_toolchain): |
||||
|
import find_depot_tools |
||||
|
depot_tools_path = find_depot_tools.add_depot_tools_to_path() |
||||
|
get_toolchain_args = [ |
||||
|
sys.executable, |
||||
|
os.path.join(depot_tools_path, |
||||
|
'win_toolchain', |
||||
|
'get_toolchain_if_necessary.py'), |
||||
|
'--output-json', json_data_file, |
||||
|
] + _GetDesiredVsToolchainHashes() |
||||
|
if force: |
||||
|
get_toolchain_args.append('--force') |
||||
|
subprocess.check_call(get_toolchain_args) |
||||
|
|
||||
|
return 0 |
||||
|
|
||||
|
|
||||
|
def GetToolchainDir(): |
||||
|
"""Gets location information about the current toolchain (must have been |
||||
|
previously updated by 'update'). This is used for the GN build.""" |
||||
|
runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs() |
||||
|
|
||||
|
# If WINDOWSSDKDIR is not set, search the default SDK path and set it. |
||||
|
if not 'WINDOWSSDKDIR' in os.environ: |
||||
|
default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\8.1' |
||||
|
if os.path.isdir(default_sdk_path): |
||||
|
os.environ['WINDOWSSDKDIR'] = default_sdk_path |
||||
|
|
||||
|
print '''vs_path = "%s" |
||||
|
sdk_path = "%s" |
||||
|
vs_version = "%s" |
||||
|
wdk_dir = "%s" |
||||
|
runtime_dirs = "%s" |
||||
|
''' % ( |
||||
|
os.environ['GYP_MSVS_OVERRIDE_PATH'], |
||||
|
os.environ['WINDOWSSDKDIR'], |
||||
|
os.environ['GYP_MSVS_VERSION'], |
||||
|
os.environ.get('WDK_DIR', ''), |
||||
|
';'.join(runtime_dll_dirs or ['None'])) |
||||
|
|
||||
|
|
||||
|
def main(): |
||||
|
commands = { |
||||
|
'update': Update, |
||||
|
'get_toolchain_dir': GetToolchainDir, |
||||
|
'copy_dlls': CopyDlls, |
||||
|
} |
||||
|
if len(sys.argv) < 2 or sys.argv[1] not in commands: |
||||
|
print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands) |
||||
|
return 1 |
||||
|
return commands[sys.argv[1]](*sys.argv[2:]) |
||||
|
|
||||
|
|
||||
|
if __name__ == '__main__': |
||||
|
sys.exit(main()) |
@ -1,14 +1,7 @@ |
|||||
# Introduction |
# Runtime functions |
||||
|
|
||||
Much of the JavaScript library is implemented in JavaScript code itself, |
Much of the JavaScript library is implemented in JavaScript code itself, |
||||
using a minimal set of C++ runtime functions callable from JavaScript. |
using a minimal set of C++ runtime functions callable from JavaScript. |
||||
Some of these are called using names that start with %, and using the flag |
Some of these are called using names that start with %, and using the flag |
||||
"--allow-natives-syntax". Others are only called by code generated by the |
"--allow-natives-syntax". Others are only called by code generated by the |
||||
code generators, and are not visible in JS, even using the % syntax. |
code generators, and are not visible in JS, even using the % syntax. |
||||
|
|
||||
<a href='Hidden comment: |
|
||||
= Details = |
|
||||
|
|
||||
Here are the V8 runtime functions, their JS names, if they are visible, |
|
||||
and their documentation. |
|
||||
<wiki:comment> |
|
@ -1,7 +1,3 @@ |
|||||
# Introduction |
# V8 C++ Style Guide |
||||
|
|
||||
In general, V8 should conform to Google's/Chrome's C++ Style Guide for new code that is written. Your V8 code should conform to them as much as possible. There will always be cases where Google/Chrome Style Guide conformity or Google/Chrome best practices are extremely cumbersome or underspecified for our use cases. We document these exceptions here. |
In general, V8 should conform to Google's/Chrome's C++ Style Guide for new code that is written. Your V8 code should conform to them as much as possible. There will always be cases where Google/Chrome Style Guide conformity or Google/Chrome best practices are extremely cumbersome or underspecified for our use cases. We document these exceptions here. |
||||
|
|
||||
# Details |
|
||||
|
|
||||
Coming Soon |
|
@ -0,0 +1,38 @@ |
|||||
|
// Copyright 2015 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/address-map.h" |
||||
|
#include "src/heap/heap.h" |
||||
|
#include "src/isolate.h" |
||||
|
#include "src/objects-inl.h" |
||||
|
|
||||
|
namespace v8 { |
||||
|
namespace internal { |
||||
|
|
||||
|
RootIndexMap::RootIndexMap(Isolate* isolate) { |
||||
|
map_ = isolate->root_index_map(); |
||||
|
if (map_ != NULL) return; |
||||
|
map_ = new HashMap(HashMap::PointersMatch); |
||||
|
for (uint32_t i = 0; i < Heap::kStrongRootListLength; i++) { |
||||
|
Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i); |
||||
|
Object* root = isolate->heap()->root(root_index); |
||||
|
// Omit root entries that can be written after initialization. They must
|
||||
|
// not be referenced through the root list in the snapshot.
|
||||
|
if (root->IsHeapObject() && |
||||
|
isolate->heap()->RootCanBeTreatedAsConstant(root_index)) { |
||||
|
HeapObject* heap_object = HeapObject::cast(root); |
||||
|
HashMap::Entry* entry = LookupEntry(map_, heap_object, false); |
||||
|
if (entry != NULL) { |
||||
|
// Some are initialized to a previous value in the root list.
|
||||
|
DCHECK_LT(GetValue(entry), i); |
||||
|
} else { |
||||
|
SetValue(LookupEntry(map_, heap_object, true), i); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
isolate->set_root_index_map(map_); |
||||
|
} |
||||
|
|
||||
|
} // namespace internal
|
||||
|
} // namespace v8
|
@ -0,0 +1,184 @@ |
|||||
|
// Copyright 2015 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_ADDRESS_MAP_H_ |
||||
|
#define V8_ADDRESS_MAP_H_ |
||||
|
|
||||
|
#include "src/assert-scope.h" |
||||
|
#include "src/hashmap.h" |
||||
|
#include "src/objects.h" |
||||
|
|
||||
|
namespace v8 { |
||||
|
namespace internal { |
||||
|
|
||||
|
class AddressMapBase { |
||||
|
protected: |
||||
|
static void SetValue(HashMap::Entry* entry, uint32_t v) { |
||||
|
entry->value = reinterpret_cast<void*>(v); |
||||
|
} |
||||
|
|
||||
|
static uint32_t GetValue(HashMap::Entry* entry) { |
||||
|
return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value)); |
||||
|
} |
||||
|
|
||||
|
inline static HashMap::Entry* LookupEntry(HashMap* map, HeapObject* obj, |
||||
|
bool insert) { |
||||
|
if (insert) { |
||||
|
map->LookupOrInsert(Key(obj), Hash(obj)); |
||||
|
} |
||||
|
return map->Lookup(Key(obj), Hash(obj)); |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
static uint32_t Hash(HeapObject* obj) { |
||||
|
return static_cast<int32_t>(reinterpret_cast<intptr_t>(obj->address())); |
||||
|
} |
||||
|
|
||||
|
static void* Key(HeapObject* obj) { |
||||
|
return reinterpret_cast<void*>(obj->address()); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
class RootIndexMap : public AddressMapBase { |
||||
|
public: |
||||
|
explicit RootIndexMap(Isolate* isolate); |
||||
|
|
||||
|
static const int kInvalidRootIndex = -1; |
||||
|
|
||||
|
int Lookup(HeapObject* obj) { |
||||
|
HashMap::Entry* entry = LookupEntry(map_, obj, false); |
||||
|
if (entry) return GetValue(entry); |
||||
|
return kInvalidRootIndex; |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
HashMap* map_; |
||||
|
|
||||
|
DISALLOW_COPY_AND_ASSIGN(RootIndexMap); |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
class BackReference { |
||||
|
public: |
||||
|
explicit BackReference(uint32_t bitfield) : bitfield_(bitfield) {} |
||||
|
|
||||
|
BackReference() : bitfield_(kInvalidValue) {} |
||||
|
|
||||
|
static BackReference SourceReference() { return BackReference(kSourceValue); } |
||||
|
|
||||
|
static BackReference GlobalProxyReference() { |
||||
|
return BackReference(kGlobalProxyValue); |
||||
|
} |
||||
|
|
||||
|
static BackReference LargeObjectReference(uint32_t index) { |
||||
|
return BackReference(SpaceBits::encode(LO_SPACE) | |
||||
|
ChunkOffsetBits::encode(index)); |
||||
|
} |
||||
|
|
||||
|
static BackReference DummyReference() { return BackReference(kDummyValue); } |
||||
|
|
||||
|
static BackReference Reference(AllocationSpace space, uint32_t chunk_index, |
||||
|
uint32_t chunk_offset) { |
||||
|
DCHECK(IsAligned(chunk_offset, kObjectAlignment)); |
||||
|
DCHECK_NE(LO_SPACE, space); |
||||
|
return BackReference( |
||||
|
SpaceBits::encode(space) | ChunkIndexBits::encode(chunk_index) | |
||||
|
ChunkOffsetBits::encode(chunk_offset >> kObjectAlignmentBits)); |
||||
|
} |
||||
|
|
||||
|
bool is_valid() const { return bitfield_ != kInvalidValue; } |
||||
|
bool is_source() const { return bitfield_ == kSourceValue; } |
||||
|
bool is_global_proxy() const { return bitfield_ == kGlobalProxyValue; } |
||||
|
|
||||
|
AllocationSpace space() const { |
||||
|
DCHECK(is_valid()); |
||||
|
return SpaceBits::decode(bitfield_); |
||||
|
} |
||||
|
|
||||
|
uint32_t chunk_offset() const { |
||||
|
DCHECK(is_valid()); |
||||
|
return ChunkOffsetBits::decode(bitfield_) << kObjectAlignmentBits; |
||||
|
} |
||||
|
|
||||
|
uint32_t large_object_index() const { |
||||
|
DCHECK(is_valid()); |
||||
|
DCHECK(chunk_index() == 0); |
||||
|
return ChunkOffsetBits::decode(bitfield_); |
||||
|
} |
||||
|
|
||||
|
uint32_t chunk_index() const { |
||||
|
DCHECK(is_valid()); |
||||
|
return ChunkIndexBits::decode(bitfield_); |
||||
|
} |
||||
|
|
||||
|
uint32_t reference() const { |
||||
|
DCHECK(is_valid()); |
||||
|
return bitfield_ & (ChunkOffsetBits::kMask | ChunkIndexBits::kMask); |
||||
|
} |
||||
|
|
||||
|
uint32_t bitfield() const { return bitfield_; } |
||||
|
|
||||
|
private: |
||||
|
static const uint32_t kInvalidValue = 0xFFFFFFFF; |
||||
|
static const uint32_t kSourceValue = 0xFFFFFFFE; |
||||
|
static const uint32_t kGlobalProxyValue = 0xFFFFFFFD; |
||||
|
static const uint32_t kDummyValue = 0xFFFFFFFC; |
||||
|
static const int kChunkOffsetSize = kPageSizeBits - kObjectAlignmentBits; |
||||
|
static const int kChunkIndexSize = 32 - kChunkOffsetSize - kSpaceTagSize; |
||||
|
|
||||
|
public: |
||||
|
static const int kMaxChunkIndex = (1 << kChunkIndexSize) - 1; |
||||
|
|
||||
|
private: |
||||
|
class ChunkOffsetBits : public BitField<uint32_t, 0, kChunkOffsetSize> {}; |
||||
|
class ChunkIndexBits |
||||
|
: public BitField<uint32_t, ChunkOffsetBits::kNext, kChunkIndexSize> {}; |
||||
|
class SpaceBits |
||||
|
: public BitField<AllocationSpace, ChunkIndexBits::kNext, kSpaceTagSize> { |
||||
|
}; |
||||
|
|
||||
|
uint32_t bitfield_; |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
// Mapping objects to their location after deserialization.
|
||||
|
// This is used during building, but not at runtime by V8.
|
||||
|
class BackReferenceMap : public AddressMapBase { |
||||
|
public: |
||||
|
BackReferenceMap() |
||||
|
: no_allocation_(), map_(new HashMap(HashMap::PointersMatch)) {} |
||||
|
|
||||
|
~BackReferenceMap() { delete map_; } |
||||
|
|
||||
|
BackReference Lookup(HeapObject* obj) { |
||||
|
HashMap::Entry* entry = LookupEntry(map_, obj, false); |
||||
|
return entry ? BackReference(GetValue(entry)) : BackReference(); |
||||
|
} |
||||
|
|
||||
|
void Add(HeapObject* obj, BackReference b) { |
||||
|
DCHECK(b.is_valid()); |
||||
|
DCHECK_NULL(LookupEntry(map_, obj, false)); |
||||
|
HashMap::Entry* entry = LookupEntry(map_, obj, true); |
||||
|
SetValue(entry, b.bitfield()); |
||||
|
} |
||||
|
|
||||
|
void AddSourceString(String* string) { |
||||
|
Add(string, BackReference::SourceReference()); |
||||
|
} |
||||
|
|
||||
|
void AddGlobalProxy(HeapObject* global_proxy) { |
||||
|
Add(global_proxy, BackReference::GlobalProxyReference()); |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
DisallowHeapAllocation no_allocation_; |
||||
|
HashMap* map_; |
||||
|
DISALLOW_COPY_AND_ASSIGN(BackReferenceMap); |
||||
|
}; |
||||
|
|
||||
|
} // namespace internal
|
||||
|
} // namespace v8
|
||||
|
|
||||
|
#endif // V8_ADDRESS_MAP_H_
|
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue