OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/allocation-site-scopes.h" | 8 #include "src/allocation-site-scopes.h" |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 2333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2344 | 2344 |
2345 Heap* heap = isolate()->heap(); | 2345 Heap* heap = isolate()->heap(); |
2346 // Reinitialize the object from the constructor map. | 2346 // Reinitialize the object from the constructor map. |
2347 heap->InitializeJSObjectFromMap(*object, *properties, *map); | 2347 heap->InitializeJSObjectFromMap(*object, *properties, *map); |
2348 | 2348 |
2349 // Restore the saved hash. | 2349 // Restore the saved hash. |
2350 object->set_hash(*hash); | 2350 object->set_hash(*hash); |
2351 } | 2351 } |
2352 | 2352 |
2353 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( | 2353 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo( |
2354 Handle<String> name, int number_of_literals, FunctionKind kind, | 2354 Handle<String> name, FunctionKind kind, Handle<Code> code, |
2355 Handle<Code> code, Handle<ScopeInfo> scope_info) { | 2355 Handle<ScopeInfo> scope_info) { |
2356 DCHECK(IsValidFunctionKind(kind)); | 2356 DCHECK(IsValidFunctionKind(kind)); |
2357 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo( | 2357 Handle<SharedFunctionInfo> shared = NewSharedFunctionInfo( |
2358 name, code, IsConstructable(kind, scope_info->language_mode())); | 2358 name, code, IsConstructable(kind, scope_info->language_mode())); |
2359 shared->set_scope_info(*scope_info); | 2359 shared->set_scope_info(*scope_info); |
2360 shared->set_outer_scope_info(*the_hole_value()); | 2360 shared->set_outer_scope_info(*the_hole_value()); |
2361 shared->set_kind(kind); | 2361 shared->set_kind(kind); |
2362 shared->set_num_literals(number_of_literals); | |
2363 if (IsGeneratorFunction(kind)) { | 2362 if (IsGeneratorFunction(kind)) { |
2364 shared->set_instance_class_name(isolate()->heap()->Generator_string()); | 2363 shared->set_instance_class_name(isolate()->heap()->Generator_string()); |
2365 } | 2364 } |
2366 return shared; | 2365 return shared; |
2367 } | 2366 } |
2368 | 2367 |
2369 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForLiteral( | 2368 Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfoForLiteral( |
2370 FunctionLiteral* literal, Handle<Script> script) { | 2369 FunctionLiteral* literal, Handle<Script> script) { |
2371 Handle<Code> code = isolate()->builtins()->CompileLazy(); | 2370 Handle<Code> code = isolate()->builtins()->CompileLazy(); |
2372 Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate())); | 2371 Handle<ScopeInfo> scope_info(ScopeInfo::Empty(isolate())); |
2373 Handle<SharedFunctionInfo> result = NewSharedFunctionInfo( | 2372 Handle<SharedFunctionInfo> result = |
2374 literal->name(), literal->materialized_literal_count(), literal->kind(), | 2373 NewSharedFunctionInfo(literal->name(), literal->kind(), code, scope_info); |
2375 code, scope_info); | |
2376 SharedFunctionInfo::InitFromFunctionLiteral(result, literal); | 2374 SharedFunctionInfo::InitFromFunctionLiteral(result, literal); |
2377 SharedFunctionInfo::SetScript(result, script); | 2375 SharedFunctionInfo::SetScript(result, script); |
2378 return result; | 2376 return result; |
2379 } | 2377 } |
2380 | 2378 |
2381 Handle<JSMessageObject> Factory::NewJSMessageObject( | 2379 Handle<JSMessageObject> Factory::NewJSMessageObject( |
2382 MessageTemplate::Template message, Handle<Object> argument, | 2380 MessageTemplate::Template message, Handle<Object> argument, |
2383 int start_position, int end_position, Handle<Object> script, | 2381 int start_position, int end_position, Handle<Object> script, |
2384 Handle<Object> stack_frames) { | 2382 Handle<Object> stack_frames) { |
2385 Handle<Map> map = message_object_map(); | 2383 Handle<Map> map = message_object_map(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2435 share->set_unique_id(isolate()->GetNextUniqueSharedFunctionInfoId()); | 2433 share->set_unique_id(isolate()->GetNextUniqueSharedFunctionInfoId()); |
2436 #endif | 2434 #endif |
2437 share->set_profiler_ticks(0); | 2435 share->set_profiler_ticks(0); |
2438 share->set_ast_node_count(0); | 2436 share->set_ast_node_count(0); |
2439 share->set_counters(0); | 2437 share->set_counters(0); |
2440 | 2438 |
2441 // Set integer fields (smi or int, depending on the architecture). | 2439 // Set integer fields (smi or int, depending on the architecture). |
2442 share->set_length(0); | 2440 share->set_length(0); |
2443 share->set_internal_formal_parameter_count(0); | 2441 share->set_internal_formal_parameter_count(0); |
2444 share->set_expected_nof_properties(0); | 2442 share->set_expected_nof_properties(0); |
2445 share->set_num_literals(0); | |
2446 share->set_start_position_and_type(0); | 2443 share->set_start_position_and_type(0); |
2447 share->set_end_position(0); | 2444 share->set_end_position(0); |
2448 share->set_function_token_position(0); | 2445 share->set_function_token_position(0); |
2449 // All compiler hints default to false or 0. | 2446 // All compiler hints default to false or 0. |
2450 share->set_compiler_hints(0); | 2447 share->set_compiler_hints(0); |
2451 share->set_opt_count_and_bailout_reason(0); | 2448 share->set_opt_count_and_bailout_reason(0); |
2452 | 2449 |
2453 // Link into the list. | 2450 // Link into the list. |
2454 Handle<Object> new_noscript_list = | 2451 Handle<Object> new_noscript_list = |
2455 WeakFixedArray::Add(noscript_shared_function_infos(), share); | 2452 WeakFixedArray::Add(noscript_shared_function_infos(), share); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2865 Handle<AccessorInfo> prototype = | 2862 Handle<AccessorInfo> prototype = |
2866 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); | 2863 Accessors::FunctionPrototypeInfo(isolate(), rw_attribs); |
2867 Descriptor d = Descriptor::AccessorConstant( | 2864 Descriptor d = Descriptor::AccessorConstant( |
2868 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); | 2865 Handle<Name>(Name::cast(prototype->name())), prototype, rw_attribs); |
2869 map->AppendDescriptor(&d); | 2866 map->AppendDescriptor(&d); |
2870 } | 2867 } |
2871 } | 2868 } |
2872 | 2869 |
2873 } // namespace internal | 2870 } // namespace internal |
2874 } // namespace v8 | 2871 } // namespace v8 |
OLD | NEW |