Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 70eec2b..0be96ea 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -6,6 +6,7 @@
#include "src/accessors.h"
#include "src/api-natives.h"
+#include "src/base/ieee754.h"
#include "src/code-stubs.h"
#include "src/extensions/externalize-string-extension.h"
#include "src/extensions/free-buffer-extension.h"
@@ -31,17 +32,15 @@
Handle<String> Bootstrapper::SourceLookup(int index) {
DCHECK(0 <= index && index < Source::GetBuiltinsCount());
Heap* heap = isolate_->heap();
- if (Source::GetSourceCache(heap)->get(index)->IsUndefined()) {
+ if (Source::GetSourceCache(heap)->get(index)->IsUndefined(isolate_)) {
// We can use external strings for the natives.
Vector<const char> source = Source::GetScriptSource(index);
NativesExternalStringResource* resource =
new NativesExternalStringResource(source.start(), source.length());
- // We do not expect this to throw an exception. Change this if it does.
- Handle<String> source_code = isolate_->factory()
- ->NewExternalStringFromOneByte(resource)
- .ToHandleChecked();
+ Handle<ExternalOneByteString> source_code =
+ isolate_->factory()->NewNativeSourceString(resource);
// Mark this external string with a special map.
- source_code->set_map(isolate_->heap()->native_source_string_map());
+ DCHECK(source_code->is_short());
Source::GetSourceCache(heap)->set(index, *source_code);
}
Handle<Object> cached_source(Source::GetSourceCache(heap)->get(index),
@@ -111,9 +110,10 @@
void DeleteNativeSources(Object* maybe_array) {
if (maybe_array->IsFixedArray()) {
FixedArray* array = FixedArray::cast(maybe_array);
+ Isolate* isolate = array->GetIsolate();
for (int i = 0; i < array->length(); i++) {
Object* natives_source = array->get(i);
- if (!natives_source->IsUndefined()) {
+ if (!natives_source->IsUndefined(isolate)) {
const NativesExternalStringResource* resource =
reinterpret_cast<const NativesExternalStringResource*>(
ExternalOneByteString::cast(natives_source)->resource());
@@ -139,7 +139,7 @@
public:
Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_proxy_template,
- v8::ExtensionConfiguration* extensions,
+ v8::ExtensionConfiguration* extensions, size_t context_snapshot_index,
GlobalContextType context_type);
~Genesis() { }
@@ -167,7 +167,7 @@
void CreateJSProxyMaps();
// Make the "arguments" and "caller" properties throw a TypeError on access.
- void AddRestrictedFunctionProperties(Handle<Map> map);
+ void AddRestrictedFunctionProperties(Handle<JSFunction> empty);
// Creates the global objects using the global proxy and the template passed
// in through the API. We call this regardless of whether we are building a
@@ -237,7 +237,7 @@
void set_state(RegisteredExtension* extension,
ExtensionTraversalState state);
private:
- HashMap map_;
+ base::HashMap map_;
DISALLOW_COPY_AND_ASSIGN(ExtensionStates);
};
@@ -325,13 +325,13 @@
Handle<Context> Bootstrapper::CreateEnvironment(
MaybeHandle<JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_proxy_template,
- v8::ExtensionConfiguration* extensions, GlobalContextType context_type) {
+ v8::ExtensionConfiguration* extensions, size_t context_snapshot_index,
+ GlobalContextType context_type) {
HandleScope scope(isolate_);
Genesis genesis(isolate_, maybe_global_proxy, global_proxy_template,
- extensions, context_type);
+ extensions, context_snapshot_index, context_type);
Handle<Context> env = genesis.result();
- if (env.is_null() ||
- (context_type != THIN_CONTEXT && !InstallExtensions(env, extensions))) {
+ if (env.is_null() || !InstallExtensions(env, extensions)) {
return Handle<Context>();
}
return scope.CloseAndEscape(env);
@@ -380,6 +380,16 @@
InstallFunction(target, name, function, name_string, attributes);
}
+Handle<JSFunction> InstallGetter(Handle<JSObject> target,
+ Handle<Name> property_name,
+ Handle<JSFunction> getter,
+ PropertyAttributes attributes = DONT_ENUM) {
+ Handle<Object> setter = target->GetIsolate()->factory()->undefined_value();
+ JSObject::DefineAccessor(target, property_name, getter, setter, attributes)
+ .Check();
+ return getter;
+}
+
Handle<JSFunction> CreateFunction(Isolate* isolate, Handle<String> name,
InstanceType type, int instance_size,
MaybeHandle<JSObject> maybe_prototype,
@@ -388,12 +398,9 @@
Factory* factory = isolate->factory();
Handle<Code> call_code(isolate->builtins()->builtin(call));
Handle<JSObject> prototype;
- static const bool kReadOnlyPrototype = false;
- static const bool kInstallConstructor = false;
return maybe_prototype.ToHandle(&prototype)
? factory->NewFunction(name, call_code, prototype, type,
- instance_size, kReadOnlyPrototype,
- kInstallConstructor, strict_function_map)
+ instance_size, strict_function_map)
: factory->NewFunctionWithoutPrototype(name, call_code,
strict_function_map);
}
@@ -457,6 +464,27 @@
len, adapt);
}
+Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base,
+ Handle<String> name, Builtins::Name call,
+ bool adapt) {
+ Isolate* const isolate = base->GetIsolate();
+ Handle<String> fun_name =
+ Name::ToFunctionName(name, isolate->factory()->get_string())
+ .ToHandleChecked();
+ Handle<JSFunction> fun =
+ SimpleCreateFunction(isolate, fun_name, call, 0, adapt);
+ InstallGetter(base, name, fun);
+ return fun;
+}
+
+Handle<JSFunction> SimpleInstallGetter(Handle<JSObject> base,
+ Handle<String> name, Builtins::Name call,
+ bool adapt, BuiltinFunctionId id) {
+ Handle<JSFunction> fun = SimpleInstallGetter(base, name, call, adapt);
+ fun->shared()->set_builtin_function_id(id);
+ return fun;
+}
+
} // namespace
void Genesis::SetFunctionInstanceDescriptor(Handle<Map> map,
@@ -469,6 +497,7 @@
PropertyAttributes roc_attribs =
static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY);
+ STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0);
Handle<AccessorInfo> length =
Accessors::FunctionLengthInfo(isolate(), roc_attribs);
{ // Add length.
@@ -476,6 +505,8 @@
length, roc_attribs);
map->AppendDescriptor(&d);
}
+
+ STATIC_ASSERT(JSFunction::kNameDescriptorIndex == 1);
Handle<AccessorInfo> name =
Accessors::FunctionNameInfo(isolate(), ro_attribs);
{ // Add name.
@@ -611,9 +642,6 @@
Map::SetPrototype(sloppy_function_without_prototype_map, empty_function);
Map::SetPrototype(sloppy_function_map_writable_prototype_, empty_function);
- // ES6 draft 03-17-2015, section 8.2.2 step 12
- AddRestrictedFunctionProperties(empty_function_map);
-
return empty_function;
}
@@ -633,17 +661,20 @@
DCHECK(function_mode == FUNCTION_WITH_WRITEABLE_PROTOTYPE ||
function_mode == FUNCTION_WITH_READONLY_PROTOTYPE ||
function_mode == FUNCTION_WITHOUT_PROTOTYPE);
+ STATIC_ASSERT(JSFunction::kLengthDescriptorIndex == 0);
{ // Add length.
Handle<AccessorInfo> length =
Accessors::FunctionLengthInfo(isolate(), roc_attribs);
- AccessorConstantDescriptor d(Handle<Name>(Name::cast(length->name())),
- length, roc_attribs);
+ AccessorConstantDescriptor d(handle(Name::cast(length->name())), length,
+ roc_attribs);
map->AppendDescriptor(&d);
}
+
+ STATIC_ASSERT(JSFunction::kNameDescriptorIndex == 1);
{ // Add name.
Handle<AccessorInfo> name =
Accessors::FunctionNameInfo(isolate(), roc_attribs);
- AccessorConstantDescriptor d(Handle<Name>(Name::cast(name->name())), name,
+ AccessorConstantDescriptor d(handle(Name::cast(name->name())), name,
roc_attribs);
map->AppendDescriptor(&d);
}
@@ -668,7 +699,7 @@
factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("ThrowTypeError"));
Handle<Code> code(isolate()->builtins()->builtin(builtin_name));
Handle<JSFunction> function =
- factory()->NewFunctionWithoutPrototype(name, code);
+ factory()->NewFunctionWithoutPrototype(name, code, true);
function->shared()->DontAdaptArguments();
// %ThrowTypeError% must not have a name property.
@@ -741,6 +772,10 @@
// This map is installed in MakeFunctionInstancePrototypeWritable.
strict_function_map_writable_prototype_ =
CreateStrictFunctionMap(FUNCTION_WITH_WRITEABLE_PROTOTYPE, empty);
+
+ // Now that the strict mode function map is available, set up the
+ // restricted "arguments" and "caller" getters.
+ AddRestrictedFunctionProperties(empty);
}
void Genesis::CreateIteratorMaps(Handle<JSFunction> empty) {
@@ -870,14 +905,14 @@
descriptors->Replace(idx, &descriptor);
}
-
-void Genesis::AddRestrictedFunctionProperties(Handle<Map> map) {
+void Genesis::AddRestrictedFunctionProperties(Handle<JSFunction> empty) {
PropertyAttributes rw_attribs = static_cast<PropertyAttributes>(DONT_ENUM);
Handle<JSFunction> thrower = GetRestrictedFunctionPropertiesThrower();
Handle<AccessorPair> accessors = factory()->NewAccessorPair();
accessors->set_getter(*thrower);
accessors->set_setter(*thrower);
+ Handle<Map> map(empty->map());
ReplaceAccessors(map, factory()->arguments_string(), rw_attribs, accessors);
ReplaceAccessors(map, factory()->caller_string(), rw_attribs, accessors);
}
@@ -885,13 +920,14 @@
static void AddToWeakNativeContextList(Context* context) {
DCHECK(context->IsNativeContext());
- Heap* heap = context->GetIsolate()->heap();
+ Isolate* isolate = context->GetIsolate();
+ Heap* heap = isolate->heap();
#ifdef DEBUG
{ // NOLINT
- DCHECK(context->next_context_link()->IsUndefined());
+ DCHECK(context->next_context_link()->IsUndefined(isolate));
// Check that context is not in the list yet.
for (Object* current = heap->native_contexts_list();
- !current->IsUndefined();
+ !current->IsUndefined(isolate);
current = Context::cast(current)->next_context_link()) {
DCHECK(current != context);
}
@@ -966,7 +1002,7 @@
FunctionTemplateInfo::cast(data->constructor()));
Handle<Object> proto_template(global_constructor->prototype_template(),
isolate());
- if (!proto_template->IsUndefined()) {
+ if (!proto_template->IsUndefined(isolate())) {
js_global_object_template =
Handle<ObjectTemplateInfo>::cast(proto_template);
}
@@ -1036,7 +1072,9 @@
global_proxy->set_native_context(*native_context());
// If we deserialized the context, the global proxy is already
// correctly set up. Otherwise it's undefined.
- DCHECK(native_context()->get(Context::GLOBAL_PROXY_INDEX)->IsUndefined() ||
+ DCHECK(native_context()
+ ->get(Context::GLOBAL_PROXY_INDEX)
+ ->IsUndefined(isolate()) ||
native_context()->global_proxy() == *global_proxy);
native_context()->set_global_proxy(*global_proxy);
}
@@ -1180,8 +1218,15 @@
// Setup the methods on the %FunctionPrototype%.
SimpleInstallFunction(prototype, factory->apply_string(),
Builtins::kFunctionPrototypeApply, 2, false);
- SimpleInstallFunction(prototype, factory->bind_string(),
- Builtins::kFunctionPrototypeBind, 1, false);
+
+ FastFunctionBindStub bind_stub(isolate);
+ Handle<JSFunction> bind_function = factory->NewFunctionWithoutPrototype(
+ factory->bind_string(), bind_stub.GetCode(), false);
+ bind_function->shared()->DontAdaptArguments();
+ bind_function->shared()->set_length(1);
+ InstallFunction(prototype, bind_function, factory->bind_string(),
+ DONT_ENUM);
+
SimpleInstallFunction(prototype, factory->call_string(),
Builtins::kFunctionPrototypeCall, 1, false);
SimpleInstallFunction(prototype, factory->toString_string(),
@@ -1324,7 +1369,11 @@
// Install the String.fromCharCode function.
SimpleInstallFunction(string_fun, "fromCharCode",
- Builtins::kStringFromCharCode, 1, false);
+ Builtins::kStringFromCharCode, 1, true);
+
+ // Install the String.fromCodePoint function.
+ SimpleInstallFunction(string_fun, "fromCodePoint",
+ Builtins::kStringFromCodePoint, 1, false);
// Create the %StringPrototype%
Handle<JSValue> prototype =
@@ -1341,6 +1390,12 @@
1, true);
SimpleInstallFunction(prototype, "charCodeAt",
Builtins::kStringPrototypeCharCodeAt, 1, true);
+ SimpleInstallFunction(prototype, "trim", Builtins::kStringPrototypeTrim, 0,
+ false);
+ SimpleInstallFunction(prototype, "trimLeft",
+ Builtins::kStringPrototypeTrimLeft, 0, false);
+ SimpleInstallFunction(prototype, "trimRight",
+ Builtins::kStringPrototypeTrimRight, 0, false);
}
{
@@ -1470,6 +1525,8 @@
0, true);
SimpleInstallFunction(prototype, "setYear", Builtins::kDatePrototypeSetYear,
1, false);
+ SimpleInstallFunction(prototype, "toJSON", Builtins::kDatePrototypeToJson,
+ 1, false);
// Install i18n fallback functions.
SimpleInstallFunction(prototype, "toLocaleString",
@@ -1528,7 +1585,7 @@
{ // -- E r r o r
Handle<JSFunction> error_fun = InstallFunction(
- global, "Error", JS_OBJECT_TYPE, JSObject::kHeaderSize,
+ global, "Error", JS_ERROR_TYPE, JSObject::kHeaderSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
InstallWithIntrinsicDefaultProto(isolate, error_fun,
Context::ERROR_FUNCTION_INDEX);
@@ -1536,7 +1593,7 @@
{ // -- E v a l E r r o r
Handle<JSFunction> eval_error_fun = InstallFunction(
- global, "EvalError", JS_OBJECT_TYPE, JSObject::kHeaderSize,
+ global, "EvalError", JS_ERROR_TYPE, JSObject::kHeaderSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
InstallWithIntrinsicDefaultProto(isolate, eval_error_fun,
Context::EVAL_ERROR_FUNCTION_INDEX);
@@ -1544,7 +1601,7 @@
{ // -- R a n g e E r r o r
Handle<JSFunction> range_error_fun = InstallFunction(
- global, "RangeError", JS_OBJECT_TYPE, JSObject::kHeaderSize,
+ global, "RangeError", JS_ERROR_TYPE, JSObject::kHeaderSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
InstallWithIntrinsicDefaultProto(isolate, range_error_fun,
Context::RANGE_ERROR_FUNCTION_INDEX);
@@ -1552,7 +1609,7 @@
{ // -- R e f e r e n c e E r r o r
Handle<JSFunction> reference_error_fun = InstallFunction(
- global, "ReferenceError", JS_OBJECT_TYPE, JSObject::kHeaderSize,
+ global, "ReferenceError", JS_ERROR_TYPE, JSObject::kHeaderSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
InstallWithIntrinsicDefaultProto(isolate, reference_error_fun,
Context::REFERENCE_ERROR_FUNCTION_INDEX);
@@ -1560,7 +1617,7 @@
{ // -- S y n t a x E r r o r
Handle<JSFunction> syntax_error_fun = InstallFunction(
- global, "SyntaxError", JS_OBJECT_TYPE, JSObject::kHeaderSize,
+ global, "SyntaxError", JS_ERROR_TYPE, JSObject::kHeaderSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
InstallWithIntrinsicDefaultProto(isolate, syntax_error_fun,
Context::SYNTAX_ERROR_FUNCTION_INDEX);
@@ -1568,7 +1625,7 @@
{ // -- T y p e E r r o r
Handle<JSFunction> type_error_fun = InstallFunction(
- global, "TypeError", JS_OBJECT_TYPE, JSObject::kHeaderSize,
+ global, "TypeError", JS_ERROR_TYPE, JSObject::kHeaderSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
InstallWithIntrinsicDefaultProto(isolate, type_error_fun,
Context::TYPE_ERROR_FUNCTION_INDEX);
@@ -1576,7 +1633,7 @@
{ // -- U R I E r r o r
Handle<JSFunction> uri_error_fun = InstallFunction(
- global, "URIError", JS_OBJECT_TYPE, JSObject::kHeaderSize,
+ global, "URIError", JS_ERROR_TYPE, JSObject::kHeaderSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
InstallWithIntrinsicDefaultProto(isolate, uri_error_fun,
Context::URI_ERROR_FUNCTION_INDEX);
@@ -1586,17 +1643,21 @@
Handle<FixedArray> embedder_data = factory->NewFixedArray(3);
native_context()->set_embedder_data(*embedder_data);
- if (context_type == THIN_CONTEXT) return;
-
{ // -- J S O N
Handle<String> name = factory->InternalizeUtf8String("JSON");
Handle<JSFunction> cons = factory->NewFunction(name);
JSFunction::SetInstancePrototype(cons,
Handle<Object>(native_context()->initial_object_prototype(), isolate));
- cons->shared()->set_instance_class_name(*name);
Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
DCHECK(json_object->IsJSObject());
JSObject::AddProperty(global, name, json_object, DONT_ENUM);
+ SimpleInstallFunction(json_object, "parse", Builtins::kJsonParse, 2, false);
+ SimpleInstallFunction(json_object, "stringify", Builtins::kJsonStringify, 3,
+ true);
+ JSObject::AddProperty(
+ json_object, factory->to_string_tag_symbol(),
+ factory->NewStringFromAsciiChecked("JSON"),
+ static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
}
{ // -- M a t h
@@ -1605,27 +1666,64 @@
JSFunction::SetInstancePrototype(
cons,
Handle<Object>(native_context()->initial_object_prototype(), isolate));
- cons->shared()->set_instance_class_name(*name);
Handle<JSObject> math = factory->NewJSObject(cons, TENURED);
DCHECK(math->IsJSObject());
JSObject::AddProperty(global, name, math, DONT_ENUM);
SimpleInstallFunction(math, "acos", Builtins::kMathAcos, 1, true);
SimpleInstallFunction(math, "asin", Builtins::kMathAsin, 1, true);
SimpleInstallFunction(math, "atan", Builtins::kMathAtan, 1, true);
+ SimpleInstallFunction(math, "atan2", Builtins::kMathAtan2, 2, true);
+ SimpleInstallFunction(math, "atanh", Builtins::kMathAtanh, 1, true);
SimpleInstallFunction(math, "ceil", Builtins::kMathCeil, 1, true);
+ SimpleInstallFunction(math, "cbrt", Builtins::kMathCbrt, 1, true);
+ SimpleInstallFunction(math, "expm1", Builtins::kMathExpm1, 1, true);
SimpleInstallFunction(math, "clz32", Builtins::kMathClz32, 1, true);
+ SimpleInstallFunction(math, "cos", Builtins::kMathCos, 1, true);
+ Handle<JSFunction> math_exp =
+ SimpleInstallFunction(math, "exp", Builtins::kMathExp, 1, true);
+ native_context()->set_math_exp(*math_exp);
Handle<JSFunction> math_floor =
SimpleInstallFunction(math, "floor", Builtins::kMathFloor, 1, true);
native_context()->set_math_floor(*math_floor);
SimpleInstallFunction(math, "fround", Builtins::kMathFround, 1, true);
SimpleInstallFunction(math, "imul", Builtins::kMathImul, 2, true);
+ Handle<JSFunction> math_log =
+ SimpleInstallFunction(math, "log", Builtins::kMathLog, 1, true);
+ native_context()->set_math_log(*math_log);
+ SimpleInstallFunction(math, "log1p", Builtins::kMathLog1p, 1, true);
+ SimpleInstallFunction(math, "log2", Builtins::kMathLog2, 1, true);
+ SimpleInstallFunction(math, "log10", Builtins::kMathLog10, 1, true);
SimpleInstallFunction(math, "max", Builtins::kMathMax, 2, false);
SimpleInstallFunction(math, "min", Builtins::kMathMin, 2, false);
SimpleInstallFunction(math, "round", Builtins::kMathRound, 1, true);
+ SimpleInstallFunction(math, "sin", Builtins::kMathSin, 1, true);
Handle<JSFunction> math_sqrt =
SimpleInstallFunction(math, "sqrt", Builtins::kMathSqrt, 1, true);
native_context()->set_math_sqrt(*math_sqrt);
+ SimpleInstallFunction(math, "tan", Builtins::kMathTan, 1, true);
SimpleInstallFunction(math, "trunc", Builtins::kMathTrunc, 1, true);
+
+ // Install math constants.
+ double const kE = base::ieee754::exp(1.0);
+ JSObject::AddProperty(
+ math, factory->NewStringFromAsciiChecked("E"), factory->NewNumber(kE),
+ static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
+ JSObject::AddProperty(
+ math, factory->NewStringFromAsciiChecked("LN10"),
+ factory->NewNumber(base::ieee754::log(10.0)),
+ static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
+ JSObject::AddProperty(
+ math, factory->NewStringFromAsciiChecked("LN2"),
+ factory->NewNumber(base::ieee754::log(2.0)),
+ static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
+ JSObject::AddProperty(
+ math, factory->NewStringFromAsciiChecked("LOG10E"),
+ factory->NewNumber(base::ieee754::log10(kE)),
+ static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
+ JSObject::AddProperty(
+ math, factory->NewStringFromAsciiChecked("LOG2E"),
+ factory->NewNumber(base::ieee754::log2(kE)),
+ static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY));
}
{ // -- A r r a y B u f f e r
@@ -1635,6 +1733,36 @@
Context::ARRAY_BUFFER_FUN_INDEX);
}
+ { // -- T y p e d A r r a y
+ Handle<JSObject> prototype =
+ factory->NewJSObject(isolate->object_function(), TENURED);
+ native_context()->set_typed_array_prototype(*prototype);
+
+ Handle<JSFunction> typed_array_fun =
+ CreateFunction(isolate, factory->InternalizeUtf8String("TypedArray"),
+ JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, prototype,
+ Builtins::kIllegal);
+
+ // Install the "constructor" property on the {prototype}.
+ JSObject::AddProperty(prototype, factory->constructor_string(),
+ typed_array_fun, DONT_ENUM);
+ native_context()->set_typed_array_function(*typed_array_fun);
+
+ // Install the "buffer", "byteOffset", "byteLength" and "length"
+ // getters on the {prototype}.
+ SimpleInstallGetter(prototype, factory->buffer_string(),
+ Builtins::kTypedArrayPrototypeBuffer, false);
+ SimpleInstallGetter(prototype, factory->byte_length_string(),
+ Builtins::kTypedArrayPrototypeByteLength, true,
+ kTypedArrayByteLength);
+ SimpleInstallGetter(prototype, factory->byte_offset_string(),
+ Builtins::kTypedArrayPrototypeByteOffset, true,
+ kTypedArrayByteOffset);
+ SimpleInstallGetter(prototype, factory->length_string(),
+ Builtins::kTypedArrayPrototypeLength, true,
+ kTypedArrayLength);
+ }
+
{ // -- T y p e d A r r a y s
#define INSTALL_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
{ \
@@ -1645,17 +1773,43 @@
}
TYPED_ARRAYS(INSTALL_TYPED_ARRAY)
#undef INSTALL_TYPED_ARRAY
+ }
- Handle<JSFunction> data_view_fun = InstallFunction(
- global, "DataView", JS_DATA_VIEW_TYPE,
- JSDataView::kSizeWithInternalFields,
- isolate->initial_object_prototype(), Builtins::kDataViewConstructor);
+ { // -- D a t a V i e w
+ Handle<JSObject> prototype =
+ factory->NewJSObject(isolate->object_function(), TENURED);
+ Handle<JSFunction> data_view_fun =
+ InstallFunction(global, "DataView", JS_DATA_VIEW_TYPE,
+ JSDataView::kSizeWithInternalFields, prototype,
+ Builtins::kDataViewConstructor);
InstallWithIntrinsicDefaultProto(isolate, data_view_fun,
Context::DATA_VIEW_FUN_INDEX);
data_view_fun->shared()->set_construct_stub(
*isolate->builtins()->DataViewConstructor_ConstructStub());
data_view_fun->shared()->set_length(3);
data_view_fun->shared()->DontAdaptArguments();
+
+ // Install the @@toStringTag property on the {prototype}.
+ JSObject::AddProperty(
+ prototype, factory->to_string_tag_symbol(),
+ factory->NewStringFromAsciiChecked("DataView"),
+ static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY));
+
+ // Install the "constructor" property on the {prototype}.
+ JSObject::AddProperty(prototype, factory->constructor_string(),
+ data_view_fun, DONT_ENUM);
+
+ // Install the "buffer", "byteOffset" and "byteLength" getters
+ // on the {prototype}.
+ SimpleInstallGetter(prototype, factory->buffer_string(),
+ Builtins::kDataViewPrototypeGetBuffer, false,
+ kDataViewBuffer);
+ SimpleInstallGetter(prototype, factory->byte_length_string(),
+ Builtins::kDataViewPrototypeGetByteLength, false,
+ kDataViewByteLength);
+ SimpleInstallGetter(prototype, factory->byte_offset_string(),
+ Builtins::kDataViewPrototypeGetByteOffset, false,
+ kDataViewByteOffset);
}
{ // -- M a p
@@ -1824,7 +1978,7 @@
function->shared()->set_instance_class_name(*arguments_string);
Handle<Map> map = factory->NewMap(
- JS_OBJECT_TYPE, JSSloppyArgumentsObject::kSize, FAST_ELEMENTS);
+ JS_ARGUMENTS_TYPE, JSSloppyArgumentsObject::kSize, FAST_ELEMENTS);
// Create the descriptor array for the arguments object.
Map::EnsureDescriptorSlack(map, 2);
@@ -1884,7 +2038,7 @@
// Create the map. Allocate one in-object field for length.
Handle<Map> map = factory->NewMap(
- JS_OBJECT_TYPE, JSStrictArgumentsObject::kSize, FAST_ELEMENTS);
+ JS_ARGUMENTS_TYPE, JSStrictArgumentsObject::kSize, FAST_ELEMENTS);
// Create the descriptor array for the arguments object.
Map::EnsureDescriptorSlack(map, 3);
@@ -1954,13 +2108,20 @@
}
} // NOLINT(readability/fn_size)
-
void Genesis::InstallTypedArray(const char* name, ElementsKind elements_kind,
Handle<JSFunction>* fun) {
Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
- Handle<JSFunction> result = InstallFunction(
- global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize,
- isolate()->initial_object_prototype(), Builtins::kIllegal);
+
+ Handle<JSObject> typed_array_prototype =
+ Handle<JSObject>(isolate()->typed_array_prototype());
+ Handle<JSFunction> typed_array_function =
+ Handle<JSFunction>(isolate()->typed_array_function());
+
+ Handle<JSObject> prototype =
+ factory()->NewJSObject(isolate()->object_function(), TENURED);
+ Handle<JSFunction> result =
+ InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize,
+ prototype, Builtins::kIllegal);
Handle<Map> initial_map = isolate()->factory()->NewMap(
JS_TYPED_ARRAY_TYPE,
@@ -1968,6 +2129,14 @@
elements_kind);
JSFunction::SetInitialMap(result, initial_map,
handle(initial_map->prototype(), isolate()));
+
+ CHECK(JSObject::SetPrototype(result, typed_array_function, false,
+ Object::DONT_THROW)
+ .FromJust());
+
+ CHECK(JSObject::SetPrototype(prototype, typed_array_prototype, false,
+ Object::DONT_THROW)
+ .FromJust());
*fun = result;
}
@@ -2191,8 +2360,6 @@
JSObject::AddProperty(global, natives_key, utils, DONT_ENUM);
break;
}
- case THIN_CONTEXT:
- break;
}
// The utils object can be removed for cases that reach this point.
@@ -2443,6 +2610,13 @@
}
{
+ // TODO(mvstanton): Remove this when MathSinh, MathCosh and MathTanh are
+ // no longer implemented in fdlibm.js.
+ SimpleInstallFunction(container, "MathExpm1", Builtins::kMathExpm1, 1,
+ true);
+ }
+
+ {
PrototypeIterator iter(native_context->sloppy_async_function_map());
Handle<JSObject> async_function_prototype(iter.GetCurrent<JSObject>());
@@ -2470,12 +2644,12 @@
Handle<JSFunction> async_function_next =
SimpleInstallFunction(container, "AsyncFunctionNext",
- Builtins::kGeneratorPrototypeNext, 2, false);
+ Builtins::kGeneratorPrototypeNext, 1, true);
Handle<JSFunction> async_function_throw =
SimpleInstallFunction(container, "AsyncFunctionThrow",
- Builtins::kGeneratorPrototypeThrow, 2, false);
- async_function_next->shared()->set_native(true);
- async_function_throw->shared()->set_native(true);
+ Builtins::kGeneratorPrototypeThrow, 1, true);
+ async_function_next->shared()->set_native(false);
+ async_function_throw->shared()->set_native(false);
}
}
}
@@ -2493,7 +2667,6 @@
isolate->factory()->ToBoolean(FLAG), NONE); \
}
- INITIALIZE_FLAG(FLAG_harmony_species)
INITIALIZE_FLAG(FLAG_intl_extra)
#undef INITIALIZE_FLAG
@@ -2503,20 +2676,16 @@
#define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \
void Genesis::InitializeGlobal_##id() {}
-EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode_regexps)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_for_in)
-EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_iterator_close)
-EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_exec)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind)
+EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_named_captures)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_property)
-EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_name)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_function_sent)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(promise_extra)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(intl_extra)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_explicit_tailcalls)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tailcalls)
-EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_instanceof)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_declarations)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_exponentiation_operator)
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_string_padding)
@@ -2524,6 +2693,7 @@
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(icu_case_mapping)
#endif
EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_async_await)
+EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_restrictive_generators)
void InstallPublicSymbol(Factory* factory, Handle<Context> native_context,
const char* name, Handle<Symbol> value) {
@@ -2539,19 +2709,6 @@
}
-void Genesis::InitializeGlobal_harmony_regexp_subclass() {
- if (!FLAG_harmony_regexp_subclass) return;
- InstallPublicSymbol(factory(), native_context(), "match",
- factory()->match_symbol());
- InstallPublicSymbol(factory(), native_context(), "replace",
- factory()->replace_symbol());
- InstallPublicSymbol(factory(), native_context(), "search",
- factory()->search_symbol());
- InstallPublicSymbol(factory(), native_context(), "split",
- factory()->split_symbol());
-}
-
-
void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
if (!FLAG_harmony_sharedarraybuffer) return;
@@ -2690,13 +2847,6 @@
}
-void Genesis::InitializeGlobal_harmony_species() {
- if (!FLAG_harmony_species) return;
- InstallPublicSymbol(factory(), native_context(), "species",
- factory()->species_symbol());
-}
-
-
Handle<JSFunction> Genesis::InstallInternalArray(Handle<JSObject> target,
const char* name,
ElementsKind elements_kind) {
@@ -2763,9 +2913,6 @@
DCHECK_EQ(builtin_index, Natives::GetIndex("runtime"));
if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false;
- // A thin context is ready at this point.
- if (context_type == THIN_CONTEXT) return true;
-
{
// Builtin function for OpaqueReference -- a JSValue-based object,
// that keeps its field isolated from JavaScript code. It may store
@@ -2814,6 +2961,14 @@
native_context()->set_object_function_prototype_map(
HeapObject::cast(object_function->initial_map()->prototype())->map());
+ // Set up the map for Object.create(null) instances.
+ Handle<Map> object_with_null_prototype_map =
+ Map::CopyInitialMap(handle(object_function->initial_map(), isolate()));
+ Map::SetPrototype(object_with_null_prototype_map,
+ isolate()->factory()->null_value());
+ native_context()->set_object_with_null_prototype_map(
+ *object_with_null_prototype_map);
+
// Store the map for the %StringPrototype% after the natives has been compiled
// and the String function has been set up.
Handle<JSFunction> string_function(native_context()->string_function());
@@ -2825,6 +2980,14 @@
Handle<JSGlobalObject> global_object =
handle(native_context()->global_object());
+ // Install Global.decodeURI.
+ SimpleInstallFunction(global_object, "decodeURI", Builtins::kGlobalDecodeURI,
+ 1, false);
+
+ // Install Global.decodeURIComponent.
+ SimpleInstallFunction(global_object, "decodeURIComponent",
+ Builtins::kGlobalDecodeURIComponent, 1, false);
+
// Install Global.encodeURI.
SimpleInstallFunction(global_object, "encodeURI", Builtins::kGlobalEncodeURI,
1, false);
@@ -2833,6 +2996,14 @@
SimpleInstallFunction(global_object, "encodeURIComponent",
Builtins::kGlobalEncodeURIComponent, 1, false);
+ // Install Global.escape.
+ SimpleInstallFunction(global_object, "escape", Builtins::kGlobalEscape, 1,
+ false);
+
+ // Install Global.unescape.
+ SimpleInstallFunction(global_object, "unescape", Builtins::kGlobalUnescape, 1,
+ false);
+
// Install Global.eval.
{
Handle<JSFunction> eval =
@@ -3071,27 +3242,18 @@
bool Genesis::InstallExperimentalNatives() {
- static const char* harmony_iterator_close_natives[] = {nullptr};
- static const char* harmony_species_natives[] = {"native harmony-species.js",
- nullptr};
static const char* harmony_explicit_tailcalls_natives[] = {nullptr};
static const char* harmony_tailcalls_natives[] = {nullptr};
- static const char* harmony_unicode_regexps_natives[] = {
- "native harmony-unicode-regexps.js", nullptr};
static const char* harmony_sharedarraybuffer_natives[] = {
"native harmony-sharedarraybuffer.js", "native harmony-atomics.js", NULL};
static const char* harmony_simd_natives[] = {"native harmony-simd.js",
nullptr};
static const char* harmony_do_expressions_natives[] = {nullptr};
static const char* harmony_for_in_natives[] = {nullptr};
- static const char* harmony_regexp_exec_natives[] = {
- "native harmony-regexp-exec.js", nullptr};
- static const char* harmony_regexp_subclass_natives[] = {nullptr};
static const char* harmony_regexp_lookbehind_natives[] = {nullptr};
- static const char* harmony_instanceof_natives[] = {nullptr};
static const char* harmony_restrictive_declarations_natives[] = {nullptr};
+ static const char* harmony_regexp_named_captures_natives[] = {nullptr};
static const char* harmony_regexp_property_natives[] = {nullptr};
- static const char* harmony_function_name_natives[] = {nullptr};
static const char* harmony_function_sent_natives[] = {nullptr};
static const char* promise_extra_natives[] = {"native promise-extra.js",
nullptr};
@@ -3109,6 +3271,7 @@
#endif
static const char* harmony_async_await_natives[] = {
"native harmony-async-await.js", nullptr};
+ static const char* harmony_restrictive_generators_natives[] = {nullptr};
for (int i = ExperimentalNatives::GetDebuggerCount();
i < ExperimentalNatives::GetBuiltinsCount(); i++) {
@@ -3295,12 +3458,12 @@
return v8::internal::ComputePointerHash(extension);
}
-
-Genesis::ExtensionStates::ExtensionStates() : map_(HashMap::PointersMatch, 8) {}
+Genesis::ExtensionStates::ExtensionStates()
+ : map_(base::HashMap::PointersMatch, 8) {}
Genesis::ExtensionTraversalState Genesis::ExtensionStates::get_state(
RegisteredExtension* extension) {
- i::HashMap::Entry* entry = map_.Lookup(extension, Hash(extension));
+ base::HashMap::Entry* entry = map_.Lookup(extension, Hash(extension));
if (entry == NULL) {
return UNVISITED;
}
@@ -3437,7 +3600,7 @@
// Configure the global object.
Handle<FunctionTemplateInfo> proxy_constructor(
FunctionTemplateInfo::cast(global_proxy_data->constructor()));
- if (!proxy_constructor->prototype_template()->IsUndefined()) {
+ if (!proxy_constructor->prototype_template()->IsUndefined(isolate())) {
Handle<ObjectTemplateInfo> global_object_data(
ObjectTemplateInfo::cast(proxy_constructor->prototype_template()));
if (!ConfigureApiObject(global_object, global_object_data)) return false;
@@ -3533,7 +3696,7 @@
int capacity = properties->Capacity();
for (int i = 0; i < capacity; i++) {
Object* raw_key(properties->KeyAt(i));
- if (properties->IsKey(raw_key)) {
+ if (properties->IsKey(isolate(), raw_key)) {
DCHECK(raw_key->IsName());
// If the property is already there we skip it.
Handle<Name> key(Name::cast(raw_key));
@@ -3544,7 +3707,7 @@
DCHECK(properties->ValueAt(i)->IsPropertyCell());
Handle<PropertyCell> cell(PropertyCell::cast(properties->ValueAt(i)));
Handle<Object> value(cell->value(), isolate());
- if (value->IsTheHole()) continue;
+ if (value->IsTheHole(isolate())) continue;
PropertyDetails details = cell->property_details();
DCHECK_EQ(kData, details.kind());
JSObject::AddProperty(to, key, value, details.attributes());
@@ -3556,7 +3719,7 @@
int capacity = properties->Capacity();
for (int i = 0; i < capacity; i++) {
Object* raw_key(properties->KeyAt(i));
- if (properties->IsKey(raw_key)) {
+ if (properties->IsKey(isolate(), raw_key)) {
DCHECK(raw_key->IsName());
// If the property is already there we skip it.
Handle<Name> key(Name::cast(raw_key));
@@ -3567,7 +3730,7 @@
Handle<Object> value = Handle<Object>(properties->ValueAt(i),
isolate());
DCHECK(!value->IsCell());
- DCHECK(!value->IsTheHole());
+ DCHECK(!value->IsTheHole(isolate()));
PropertyDetails details = properties->DetailsAt(i);
DCHECK_EQ(kData, details.kind());
JSObject::AddProperty(to, key, value, details.attributes());
@@ -3644,7 +3807,7 @@
MaybeHandle<JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_proxy_template,
v8::ExtensionConfiguration* extensions,
- GlobalContextType context_type)
+ size_t context_snapshot_index, GlobalContextType context_type)
: isolate_(isolate), active_(isolate->bootstrapper()) {
NoTrackDoubleFieldsForSerializerScope disable_scope(isolate);
result_ = Handle<Context>::null();
@@ -3673,7 +3836,8 @@
// a snapshot. Otherwise we have to build the context from scratch.
// Also create a context from scratch to expose natives, if required by flag.
if (!isolate->initialized_from_snapshot() ||
- !Snapshot::NewContextFromSnapshot(isolate, global_proxy)
+ !Snapshot::NewContextFromSnapshot(isolate, global_proxy,
+ context_snapshot_index)
.ToHandle(&native_context_)) {
native_context_ = Handle<Context>();
}
@@ -3715,10 +3879,9 @@
MakeFunctionInstancePrototypeWritable();
- if (context_type != THIN_CONTEXT) {
- if (!InstallExtraNatives()) return;
- if (!ConfigureGlobalObjects(global_proxy_template)) return;
- }
+ if (!InstallExtraNatives()) return;
+ if (!ConfigureGlobalObjects(global_proxy_template)) return;
+
isolate->counters()->contexts_created_from_scratch()->Increment();
// Re-initialize the counter because it got incremented during snapshot
// creation.