| Index: src/factory.cc
|
| diff --git a/src/factory.cc b/src/factory.cc
|
| index 1dd246fc487431c7289047d3e62221d91bc866b6..6da9a2e0b24447fb58cdc46b6731e85e8743e7a0 100644
|
| --- a/src/factory.cc
|
| +++ b/src/factory.cc
|
| @@ -132,11 +132,14 @@ Handle<ObjectHashSet> Factory::NewObjectHashSet(int at_least_space_for) {
|
| }
|
|
|
|
|
| -Handle<ObjectHashTable> Factory::NewObjectHashTable(int at_least_space_for) {
|
| +Handle<ObjectHashTable> Factory::NewObjectHashTable(
|
| + int at_least_space_for,
|
| + MinimumCapacity capacity_option) {
|
| ASSERT(0 <= at_least_space_for);
|
| CALL_HEAP_FUNCTION(isolate(),
|
| ObjectHashTable::Allocate(isolate()->heap(),
|
| - at_least_space_for),
|
| + at_least_space_for,
|
| + capacity_option),
|
| ObjectHashTable);
|
| }
|
|
|
| @@ -147,7 +150,7 @@ Handle<WeakHashTable> Factory::NewWeakHashTable(int at_least_space_for) {
|
| isolate(),
|
| WeakHashTable::Allocate(isolate()->heap(),
|
| at_least_space_for,
|
| - WeakHashTable::USE_DEFAULT_MINIMUM_CAPACITY,
|
| + USE_DEFAULT_MINIMUM_CAPACITY,
|
| TENURED),
|
| WeakHashTable);
|
| }
|
| @@ -307,8 +310,7 @@ Handle<String> ConcatStringContent(Handle<StringType> result,
|
| Handle<String> Factory::NewFlatConcatString(Handle<String> first,
|
| Handle<String> second) {
|
| int total_length = first->length() + second->length();
|
| - if (first->IsOneByteRepresentationUnderneath() &&
|
| - second->IsOneByteRepresentationUnderneath()) {
|
| + if (first->IsOneByteRepresentation() && second->IsOneByteRepresentation()) {
|
| return ConcatStringContent<uint8_t>(
|
| NewRawOneByteString(total_length), first, second);
|
| } else {
|
| @@ -363,6 +365,14 @@ Handle<Symbol> Factory::NewSymbol() {
|
| }
|
|
|
|
|
| +Handle<Symbol> Factory::NewPrivateSymbol() {
|
| + CALL_HEAP_FUNCTION(
|
| + isolate(),
|
| + isolate()->heap()->AllocatePrivateSymbol(),
|
| + Symbol);
|
| +}
|
| +
|
| +
|
| Handle<Context> Factory::NewNativeContext() {
|
| CALL_HEAP_FUNCTION(
|
| isolate(),
|
| @@ -573,10 +583,32 @@ Handle<Map> Factory::NewMap(InstanceType type,
|
|
|
|
|
| Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
|
| - CALL_HEAP_FUNCTION(
|
| - isolate(),
|
| - isolate()->heap()->AllocateFunctionPrototype(*function),
|
| - JSObject);
|
| + // Make sure to use globals from the function's context, since the function
|
| + // can be from a different context.
|
| + Handle<Context> native_context(function->context()->native_context());
|
| + Handle<Map> new_map;
|
| + if (function->shared()->is_generator()) {
|
| + // Generator prototypes can share maps since they don't have "constructor"
|
| + // properties.
|
| + new_map = handle(native_context->generator_object_prototype_map());
|
| + } else {
|
| + // Each function prototype gets a fresh map to avoid unwanted sharing of
|
| + // maps between prototypes of different constructors.
|
| + Handle<JSFunction> object_function(native_context->object_function());
|
| + ASSERT(object_function->has_initial_map());
|
| + new_map = Map::Copy(handle(object_function->initial_map()));
|
| + }
|
| +
|
| + Handle<JSObject> prototype = NewJSObjectFromMap(new_map);
|
| +
|
| + if (!function->shared()->is_generator()) {
|
| + JSObject::SetLocalPropertyIgnoreAttributes(prototype,
|
| + constructor_string(),
|
| + function,
|
| + DONT_ENUM);
|
| + }
|
| +
|
| + return prototype;
|
| }
|
|
|
|
|
| @@ -1047,6 +1079,7 @@ Handle<String> Factory::InternalizedStringFromString(Handle<String> value) {
|
|
|
| Handle<JSObject> Factory::NewJSObject(Handle<JSFunction> constructor,
|
| PretenureFlag pretenure) {
|
| + JSFunction::EnsureHasInitialMap(constructor);
|
| CALL_HEAP_FUNCTION(
|
| isolate(),
|
| isolate()->heap()->AllocateJSObject(*constructor, pretenure), JSObject);
|
| @@ -1193,6 +1226,19 @@ void Factory::SetContent(Handle<JSArray> array,
|
| }
|
|
|
|
|
| +Handle<JSGeneratorObject> Factory::NewJSGeneratorObject(
|
| + Handle<JSFunction> function) {
|
| + ASSERT(function->shared()->is_generator());
|
| + JSFunction::EnsureHasInitialMap(function);
|
| + Handle<Map> map(function->initial_map());
|
| + ASSERT(map->instance_type() == JS_GENERATOR_OBJECT_TYPE);
|
| + CALL_HEAP_FUNCTION(
|
| + isolate(),
|
| + isolate()->heap()->AllocateJSObjectFromMap(*map),
|
| + JSGeneratorObject);
|
| +}
|
| +
|
| +
|
| Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
|
| Handle<JSFunction> array_buffer_fun(
|
| isolate()->context()->native_context()->array_buffer_fun());
|
|
|