diff options
Diffstat (limited to 'deps/v8/src/factory.cc')
-rw-r--r-- | deps/v8/src/factory.cc | 99 |
1 files changed, 41 insertions, 58 deletions
diff --git a/deps/v8/src/factory.cc b/deps/v8/src/factory.cc index 15ddb5ff43..41c3cb5eaa 100644 --- a/deps/v8/src/factory.cc +++ b/deps/v8/src/factory.cc @@ -112,12 +112,12 @@ Factory::NewSloppyBlockWithEvalContextExtension( return result; } - Handle<Oddball> Factory::NewOddball(Handle<Map> map, const char* to_string, - Handle<Object> to_number, + Handle<Object> to_number, bool to_boolean, const char* type_of, byte kind) { Handle<Oddball> oddball = New<Oddball>(map, OLD_SPACE); - Oddball::Initialize(isolate(), oddball, to_string, to_number, type_of, kind); + Oddball::Initialize(isolate(), oddball, to_string, to_number, to_boolean, + type_of, kind); return oddball; } @@ -800,6 +800,22 @@ Handle<Context> Factory::NewCatchContext(Handle<JSFunction> function, return context; } +Handle<Context> Factory::NewDebugEvaluateContext(Handle<Context> previous, + Handle<JSReceiver> extension, + Handle<Context> wrapped, + Handle<StringSet> whitelist) { + STATIC_ASSERT(Context::WHITE_LIST_INDEX == Context::MIN_CONTEXT_SLOTS + 1); + Handle<FixedArray> array = NewFixedArray(Context::MIN_CONTEXT_SLOTS + 2); + array->set_map_no_write_barrier(*debug_evaluate_context_map()); + Handle<Context> c = Handle<Context>::cast(array); + c->set_closure(wrapped.is_null() ? previous->closure() : wrapped->closure()); + c->set_previous(*previous); + c->set_native_context(previous->native_context()); + if (!extension.is_null()) c->set(Context::EXTENSION_INDEX, *extension); + if (!wrapped.is_null()) c->set(Context::WRAPPED_CONTEXT_INDEX, *wrapped); + if (!whitelist.is_null()) c->set(Context::WHITE_LIST_INDEX, *whitelist); + return c; +} Handle<Context> Factory::NewWithContext(Handle<JSFunction> function, Handle<Context> previous, @@ -859,6 +875,7 @@ Handle<AccessorInfo> Factory::NewAccessorInfo() { Handle<AccessorInfo> info = Handle<AccessorInfo>::cast(NewStruct(ACCESSOR_INFO_TYPE)); info->set_flag(0); // Must clear the flag, it was initialized as undefined. + info->set_is_sloppy(true); return info; } @@ -1350,33 +1367,8 @@ Handle<JSFunction> Factory::NewFunctionFromSharedFunctionInfo( info->ResetForNewContext(isolate()->heap()->global_ic_age()); } - if (FLAG_always_opt && info->allows_lazy_compilation()) { - result->MarkForOptimization(); - } - - CodeAndLiterals cached = info->SearchOptimizedCodeMap( - context->native_context(), BailoutId::None()); - if (cached.code != nullptr) { - // Caching of optimized code enabled and optimized code found. - DCHECK(!cached.code->marked_for_deoptimization()); - DCHECK(result->shared()->is_compiled()); - result->ReplaceCode(cached.code); - } - - if (cached.literals != nullptr) { - result->set_literals(cached.literals); - } else { - int number_of_literals = info->num_literals(); - Handle<LiteralsArray> literals = - LiteralsArray::New(isolate(), handle(info->feedback_vector()), - number_of_literals, pretenure); - result->set_literals(*literals); - - // Cache context-specific literals. - Handle<Context> native_context(context->native_context()); - SharedFunctionInfo::AddLiteralsToOptimizedCodeMap(info, native_context, - literals); - } + // Give compiler a chance to pre-initialize. + Compiler::PostInstantiation(result, pretenure); return result; } @@ -1507,6 +1499,14 @@ Handle<JSObject> Factory::NewJSObjectWithMemento( JSObject); } +Handle<JSObject> Factory::NewJSObjectWithNullProto() { + Handle<JSObject> result = NewJSObject(isolate()->object_function()); + Handle<Map> new_map = + Map::Copy(Handle<Map>(result->map()), "ObjectWithNullProto"); + Map::SetPrototype(new_map, null_value()); + JSObject::MigrateToMap(result, new_map); + return result; +} Handle<JSModule> Factory::NewJSModule(Handle<Context> context, Handle<ScopeInfo> scope_info) { @@ -1596,11 +1596,9 @@ Handle<JSObject> Factory::NewJSObjectFromMap( Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, - Strength strength, PretenureFlag pretenure) { - Map* map = isolate()->get_initial_js_array_map(elements_kind, strength); + Map* map = isolate()->get_initial_js_array_map(elements_kind); if (map == nullptr) { - DCHECK(strength == Strength::WEAK); Context* native_context = isolate()->context()->native_context(); JSFunction* array_function = native_context->array_function(); map = array_function->initial_map(); @@ -1608,23 +1606,21 @@ Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, return Handle<JSArray>::cast(NewJSObjectFromMap(handle(map), pretenure)); } - Handle<JSArray> Factory::NewJSArray(ElementsKind elements_kind, int length, - int capacity, Strength strength, + int capacity, ArrayStorageAllocationMode mode, PretenureFlag pretenure) { - Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); + Handle<JSArray> array = NewJSArray(elements_kind, pretenure); NewJSArrayStorage(array, length, capacity, mode); return array; } - Handle<JSArray> Factory::NewJSArrayWithElements(Handle<FixedArrayBase> elements, ElementsKind elements_kind, - int length, Strength strength, + int length, PretenureFlag pretenure) { DCHECK(length <= elements->length()); - Handle<JSArray> array = NewJSArray(elements_kind, strength, pretenure); + Handle<JSArray> array = NewJSArray(elements_kind, pretenure); array->set_elements(*elements); array->set_length(Smi::FromInt(length)); @@ -2071,16 +2067,13 @@ void Factory::ReinitializeJSGlobalProxy(Handle<JSGlobalProxy> object, object->set_hash(*hash); } - Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( Handle<String> name, int number_of_literals, FunctionKind kind, - Handle<Code> code, Handle<ScopeInfo> scope_info, - Handle<TypeFeedbackVector> feedback_vector) { + Handle<Code> code, Handle<ScopeInfo> scope_info) { DCHECK(IsValidFunctionKind(kind)); Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo( name, code, IsConstructable(kind, scope_info->language_mode())); shared->set_scope_info(*scope_info); - shared->set_feedback_vector(*feedback_vector); shared->set_kind(kind); shared->set_num_literals(number_of_literals); if (IsGeneratorFunction(kind)) { @@ -2136,7 +2129,7 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER); share->set_script(*undefined_value(), SKIP_WRITE_BARRIER); share->set_debug_info(DebugInfo::uninitialized(), SKIP_WRITE_BARRIER); - share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER); + share->set_function_identifier(*undefined_value(), SKIP_WRITE_BARRIER); StaticFeedbackVectorSpec empty_spec; Handle<TypeFeedbackMetadata> feedback_metadata = TypeFeedbackMetadata::New(isolate(), &empty_spec); @@ -2300,7 +2293,6 @@ Handle<JSWeakMap> Factory::NewJSWeakMap() { Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, int number_of_properties, - bool is_strong, bool* is_result_from_cache) { const int kMapCacheSize = 128; @@ -2309,29 +2301,21 @@ Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, isolate()->bootstrapper()->IsActive()) { *is_result_from_cache = false; Handle<Map> map = Map::Create(isolate(), number_of_properties); - if (is_strong) map->set_is_strong(); return map; } *is_result_from_cache = true; if (number_of_properties == 0) { // Reuse the initial map of the Object function if the literal has no - // predeclared properties, or the strong map if strong. - return handle(is_strong - ? context->js_object_strong_map() - : context->object_function()->initial_map(), isolate()); + // predeclared properties. + return handle(context->object_function()->initial_map(), isolate()); } int cache_index = number_of_properties - 1; - Handle<Object> maybe_cache(is_strong ? context->strong_map_cache() - : context->map_cache(), isolate()); + Handle<Object> maybe_cache(context->map_cache(), isolate()); if (maybe_cache->IsUndefined()) { // Allocate the new map cache for the native context. maybe_cache = NewFixedArray(kMapCacheSize, TENURED); - if (is_strong) { - context->set_strong_map_cache(*maybe_cache); - } else { - context->set_map_cache(*maybe_cache); - } + context->set_map_cache(*maybe_cache); } else { // Check to see whether there is a matching element in the cache. Handle<FixedArray> cache = Handle<FixedArray>::cast(maybe_cache); @@ -2346,7 +2330,6 @@ Handle<Map> Factory::ObjectLiteralMapFromCache(Handle<Context> context, // Create a new map and add it to the cache. Handle<FixedArray> cache = Handle<FixedArray>::cast(maybe_cache); Handle<Map> map = Map::Create(isolate(), number_of_properties); - if (is_strong) map->set_is_strong(); Handle<WeakCell> cell = NewWeakCell(map); cache->set(cache_index, *cell); return map; |