Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Side by Side Diff: src/objects.cc

Issue 1347243004: [strong] Implement revised strong class semantics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: \cl feedback Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/messages.h ('k') | src/runtime/runtime-classes.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 10494 matching lines...) Expand 10 before | Expand all | Expand 10 after
10505 Handle<Map> initial_map(function->initial_map(), isolate); 10505 Handle<Map> initial_map(function->initial_map(), isolate);
10506 10506
10507 if (!initial_map->GetIsolate()->bootstrapper()->IsActive() && 10507 if (!initial_map->GetIsolate()->bootstrapper()->IsActive() &&
10508 initial_map->instance_type() == JS_OBJECT_TYPE) { 10508 initial_map->instance_type() == JS_OBJECT_TYPE) {
10509 // Put the value in the initial map field until an initial map is needed. 10509 // Put the value in the initial map field until an initial map is needed.
10510 // At that point, a new initial map is created and the prototype is put 10510 // At that point, a new initial map is created and the prototype is put
10511 // into the initial map where it belongs. 10511 // into the initial map where it belongs.
10512 function->set_prototype_or_initial_map(*value); 10512 function->set_prototype_or_initial_map(*value);
10513 } else { 10513 } else {
10514 Handle<Map> new_map = Map::Copy(initial_map, "SetInstancePrototype"); 10514 Handle<Map> new_map = Map::Copy(initial_map, "SetInstancePrototype");
10515 if (function->map()->is_strong()) {
10516 new_map->set_is_strong();
10517 }
10515 JSFunction::SetInitialMap(function, new_map, value); 10518 JSFunction::SetInitialMap(function, new_map, value);
10516 10519
10517 // If the function is used as the global Array function, cache the 10520 // If the function is used as the global Array function, cache the
10518 // updated initial maps (and transitioned versions) in the native context. 10521 // updated initial maps (and transitioned versions) in the native context.
10519 Handle<Context> native_context(function->context()->native_context(), 10522 Handle<Context> native_context(function->context()->native_context(),
10520 isolate); 10523 isolate);
10521 Handle<Object> array_function( 10524 Handle<Object> array_function(
10522 native_context->get(Context::ARRAY_FUNCTION_INDEX), isolate); 10525 native_context->get(Context::ARRAY_FUNCTION_INDEX), isolate);
10523 if (array_function->IsJSFunction() && 10526 if (array_function->IsJSFunction() &&
10524 *function == JSFunction::cast(*array_function)) { 10527 *function == JSFunction::cast(*array_function)) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
10629 if (function->shared()->is_generator()) { 10632 if (function->shared()->is_generator()) {
10630 instance_type = JS_GENERATOR_OBJECT_TYPE; 10633 instance_type = JS_GENERATOR_OBJECT_TYPE;
10631 instance_size = JSGeneratorObject::kSize; 10634 instance_size = JSGeneratorObject::kSize;
10632 in_object_properties = 0; 10635 in_object_properties = 0;
10633 } else { 10636 } else {
10634 instance_type = JS_OBJECT_TYPE; 10637 instance_type = JS_OBJECT_TYPE;
10635 instance_size = function->shared()->CalculateInstanceSize(); 10638 instance_size = function->shared()->CalculateInstanceSize();
10636 in_object_properties = function->shared()->CalculateInObjectProperties(); 10639 in_object_properties = function->shared()->CalculateInObjectProperties();
10637 } 10640 }
10638 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size); 10641 Handle<Map> map = isolate->factory()->NewMap(instance_type, instance_size);
10642 if (function->map()->is_strong()) {
10643 map->set_is_strong();
10644 }
10639 10645
10640 // Fetch or allocate prototype. 10646 // Fetch or allocate prototype.
10641 Handle<Object> prototype; 10647 Handle<Object> prototype;
10642 if (function->has_instance_prototype()) { 10648 if (function->has_instance_prototype()) {
10643 prototype = handle(function->instance_prototype(), isolate); 10649 prototype = handle(function->instance_prototype(), isolate);
10644 } else { 10650 } else {
10645 prototype = isolate->factory()->NewFunctionPrototype(function); 10651 prototype = isolate->factory()->NewFunctionPrototype(function);
10646 } 10652 }
10647 map->SetInObjectProperties(in_object_properties); 10653 map->SetInObjectProperties(in_object_properties);
10648 map->set_unused_property_fields(in_object_properties); 10654 map->set_unused_property_fields(in_object_properties);
10649 DCHECK(map->has_fast_object_elements()); 10655 DCHECK(map->has_fast_object_elements());
10650 10656
10651 // Finally link initial map and constructor function. 10657 // Finally link initial map and constructor function.
10652 JSFunction::SetInitialMap(function, map, Handle<JSReceiver>::cast(prototype)); 10658 DCHECK(prototype->IsJSReceiver());
10659 JSFunction::SetInitialMap(function, map, prototype);
10653 10660
10654 if (!function->shared()->is_generator()) { 10661 if (!function->shared()->is_generator()) {
10655 function->StartInobjectSlackTracking(); 10662 function->StartInobjectSlackTracking();
10656 } 10663 }
10657 } 10664 }
10658 10665
10659 10666
10660 void JSFunction::SetInstanceClassName(String* name) { 10667 void JSFunction::SetInstanceClassName(String* name) {
10661 shared()->set_instance_class_name(name); 10668 shared()->set_instance_class_name(name);
10662 } 10669 }
(...skipping 5912 matching lines...) Expand 10 before | Expand all | Expand 10 after
16575 if (cell->value() != *new_value) { 16582 if (cell->value() != *new_value) {
16576 cell->set_value(*new_value); 16583 cell->set_value(*new_value);
16577 Isolate* isolate = cell->GetIsolate(); 16584 Isolate* isolate = cell->GetIsolate();
16578 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16585 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16579 isolate, DependentCode::kPropertyCellChangedGroup); 16586 isolate, DependentCode::kPropertyCellChangedGroup);
16580 } 16587 }
16581 } 16588 }
16582 16589
16583 } // namespace internal 16590 } // namespace internal
16584 } // namespace v8 16591 } // namespace v8
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/runtime/runtime-classes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698