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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/extensions/externalize-string-extension.h" | 9 #include "src/extensions/externalize-string-extension.h" |
10 #include "src/extensions/free-buffer-extension.h" | 10 #include "src/extensions/free-buffer-extension.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 Handle<Context> env = genesis.result(); | 335 Handle<Context> env = genesis.result(); |
336 if (env.is_null() || !InstallExtensions(env, extensions)) { | 336 if (env.is_null() || !InstallExtensions(env, extensions)) { |
337 return Handle<Context>(); | 337 return Handle<Context>(); |
338 } | 338 } |
339 return scope.CloseAndEscape(env); | 339 return scope.CloseAndEscape(env); |
340 } | 340 } |
341 | 341 |
342 | 342 |
343 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { | 343 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { |
344 // object.__proto__ = proto; | 344 // object.__proto__ = proto; |
345 Handle<Map> old_to_map = Handle<Map>(object->map()); | 345 Handle<Map> old_map = Handle<Map>(object->map()); |
346 Handle<Map> new_to_map = Map::Copy(old_to_map); | 346 Handle<Map> new_map = Map::Copy(old_map); |
347 new_to_map->set_prototype(*proto); | 347 new_map->set_prototype(*proto); |
348 object->set_map(*new_to_map); | 348 JSObject::MigrateToMap(object, new_map); |
349 } | 349 } |
350 | 350 |
351 | 351 |
352 void Bootstrapper::DetachGlobal(Handle<Context> env) { | 352 void Bootstrapper::DetachGlobal(Handle<Context> env) { |
353 Factory* factory = env->GetIsolate()->factory(); | 353 Factory* factory = env->GetIsolate()->factory(); |
354 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); | 354 Handle<JSGlobalProxy> global_proxy(JSGlobalProxy::cast(env->global_proxy())); |
355 global_proxy->set_native_context(*factory->null_value()); | 355 global_proxy->set_native_context(*factory->null_value()); |
356 SetObjectPrototype(global_proxy, factory->null_value()); | 356 SetObjectPrototype(global_proxy, factory->null_value()); |
357 } | 357 } |
358 | 358 |
(...skipping 2174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2533 void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) { | 2533 void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) { |
2534 HandleScope outer(isolate()); | 2534 HandleScope outer(isolate()); |
2535 | 2535 |
2536 ASSERT(!from->IsJSArray()); | 2536 ASSERT(!from->IsJSArray()); |
2537 ASSERT(!to->IsJSArray()); | 2537 ASSERT(!to->IsJSArray()); |
2538 | 2538 |
2539 TransferNamedProperties(from, to); | 2539 TransferNamedProperties(from, to); |
2540 TransferIndexedProperties(from, to); | 2540 TransferIndexedProperties(from, to); |
2541 | 2541 |
2542 // Transfer the prototype (new map is needed). | 2542 // Transfer the prototype (new map is needed). |
2543 Handle<Map> old_to_map = Handle<Map>(to->map()); | 2543 Handle<Object> proto(from->map()->prototype(), isolate()); |
2544 Handle<Map> new_to_map = Map::Copy(old_to_map); | 2544 SetObjectPrototype(to, proto); |
2545 new_to_map->set_prototype(from->map()->prototype()); | |
2546 to->set_map(*new_to_map); | |
2547 } | 2545 } |
2548 | 2546 |
2549 | 2547 |
2550 void Genesis::MakeFunctionInstancePrototypeWritable() { | 2548 void Genesis::MakeFunctionInstancePrototypeWritable() { |
2551 // The maps with writable prototype are created in CreateEmptyFunction | 2549 // The maps with writable prototype are created in CreateEmptyFunction |
2552 // and CreateStrictModeFunctionMaps respectively. Initially the maps are | 2550 // and CreateStrictModeFunctionMaps respectively. Initially the maps are |
2553 // created with read-only prototype for JS builtins processing. | 2551 // created with read-only prototype for JS builtins processing. |
2554 ASSERT(!sloppy_function_map_writable_prototype_.is_null()); | 2552 ASSERT(!sloppy_function_map_writable_prototype_.is_null()); |
2555 ASSERT(!strict_function_map_writable_prototype_.is_null()); | 2553 ASSERT(!strict_function_map_writable_prototype_.is_null()); |
2556 | 2554 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2742 return from + sizeof(NestingCounterType); | 2740 return from + sizeof(NestingCounterType); |
2743 } | 2741 } |
2744 | 2742 |
2745 | 2743 |
2746 // Called when the top-level V8 mutex is destroyed. | 2744 // Called when the top-level V8 mutex is destroyed. |
2747 void Bootstrapper::FreeThreadResources() { | 2745 void Bootstrapper::FreeThreadResources() { |
2748 ASSERT(!IsActive()); | 2746 ASSERT(!IsActive()); |
2749 } | 2747 } |
2750 | 2748 |
2751 } } // namespace v8::internal | 2749 } } // namespace v8::internal |
OLD | NEW |