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

Side by Side Diff: runtime/vm/object.cc

Issue 1544583002: For background compilation we copy ICData so that it is immutable during comnpilation. However, we … (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: l Created 5 years 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 7015 matching lines...) Expand 10 before | Expand all | Expand 10 after
7026 const intptr_t restored_length = ICData::Cast(Object::Handle( 7026 const intptr_t restored_length = ICData::Cast(Object::Handle(
7027 zone, saved_ic_data.At(saved_length - 1))).deopt_id() + 1; 7027 zone, saved_ic_data.At(saved_length - 1))).deopt_id() + 1;
7028 deopt_id_to_ic_data->SetLength(restored_length); 7028 deopt_id_to_ic_data->SetLength(restored_length);
7029 for (intptr_t i = 0; i < restored_length; i++) { 7029 for (intptr_t i = 0; i < restored_length; i++) {
7030 (*deopt_id_to_ic_data)[i] = NULL; 7030 (*deopt_id_to_ic_data)[i] = NULL;
7031 } 7031 }
7032 for (intptr_t i = 1; i < saved_length; i++) { 7032 for (intptr_t i = 1; i < saved_length; i++) {
7033 ICData& ic_data = ICData::ZoneHandle(zone); 7033 ICData& ic_data = ICData::ZoneHandle(zone);
7034 ic_data ^= saved_ic_data.At(i); 7034 ic_data ^= saved_ic_data.At(i);
7035 if (clone_descriptors) { 7035 if (clone_descriptors) {
7036 ICData& original_ic_data = ICData::Handle(zone, ic_data.raw());
7036 ic_data = ICData::CloneDescriptor(ic_data); 7037 ic_data = ICData::CloneDescriptor(ic_data);
7038 ic_data.SetOriginal(original_ic_data);
7037 } 7039 }
7038 (*deopt_id_to_ic_data)[ic_data.deopt_id()] = &ic_data; 7040 (*deopt_id_to_ic_data)[ic_data.deopt_id()] = &ic_data;
7039 } 7041 }
7040 } 7042 }
7041 } 7043 }
7042 7044
7043 7045
7044 void Function::set_ic_data_array(const Array& value) const { 7046 void Function::set_ic_data_array(const Array& value) const {
7045 StorePointer(&raw_ptr()->ic_data_array_, value.raw()); 7047 StorePointer(&raw_ptr()->ic_data_array_, value.raw());
7046 } 7048 }
(...skipping 5122 matching lines...) Expand 10 before | Expand all | Expand 10 after
12169 const char* ICData::ToCString() const { 12171 const char* ICData::ToCString() const {
12170 const String& name = String::Handle(target_name()); 12172 const String& name = String::Handle(target_name());
12171 const intptr_t num_args = NumArgsTested(); 12173 const intptr_t num_args = NumArgsTested();
12172 const intptr_t num_checks = NumberOfChecks(); 12174 const intptr_t num_checks = NumberOfChecks();
12173 return OS::SCreate(Thread::Current()->zone(), 12175 return OS::SCreate(Thread::Current()->zone(),
12174 "ICData target:'%s' num-args: %" Pd " num-checks: %" Pd "", 12176 "ICData target:'%s' num-args: %" Pd " num-checks: %" Pd "",
12175 name.ToCString(), num_args, num_checks); 12177 name.ToCString(), num_args, num_checks);
12176 } 12178 }
12177 12179
12178 12180
12181 RawFunction* ICData::Owner() const {
12182 Object& obj = Object::Handle(raw_ptr()->owner_);
12183 if (obj.IsFunction()) {
12184 return Function::Cast(obj).raw();
12185 } else {
12186 ICData& original = ICData::Handle();
12187 original ^= obj.raw();
12188 return original.Owner();
12189 }
12190 }
12191
12192
12193 RawICData* ICData::Original() const {
12194 Object& obj = Object::Handle(raw_ptr()->owner_);
12195 if (obj.IsNull()) {
12196 return ICData::null();
12197 } else if (obj.IsFunction()) {
12198 return this->raw();
12199 } else {
12200 return ICData::RawCast(obj.raw());
12201 }
12202 }
12203
12204
12205 void ICData::SetOriginal(const ICData& value) const {
zra 2015/12/21 19:31:47 It looks like there is an assumption that the orig
srdjan 2015/12/21 20:22:49 Done.
12206 ASSERT(!value.IsNull());
12207 StorePointer(&raw_ptr()->owner_, reinterpret_cast<RawObject*>(value.raw()));
12208 }
12209
12210
12179 void ICData::set_owner(const Function& value) const { 12211 void ICData::set_owner(const Function& value) const {
12180 ASSERT(!value.IsNull()); 12212 ASSERT(!value.IsNull());
12181 StorePointer(&raw_ptr()->owner_, value.raw()); 12213 StorePointer(&raw_ptr()->owner_, reinterpret_cast<RawObject*>(value.raw()));
12182 } 12214 }
12183 12215
12184 12216
12185 void ICData::set_target_name(const String& value) const { 12217 void ICData::set_target_name(const String& value) const {
12186 ASSERT(!value.IsNull()); 12218 ASSERT(!value.IsNull());
12187 StorePointer(&raw_ptr()->target_name_, value.raw()); 12219 StorePointer(&raw_ptr()->target_name_, value.raw());
12188 } 12220 }
12189 12221
12190 12222
12191 void ICData::set_arguments_descriptor(const Array& value) const { 12223 void ICData::set_arguments_descriptor(const Array& value) const {
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
12810 deopt_id, 12842 deopt_id,
12811 num_args_tested)); 12843 num_args_tested));
12812 result.set_ic_data_array( 12844 result.set_ic_data_array(
12813 Array::Handle(zone, NewEmptyICDataArray(num_args_tested))); 12845 Array::Handle(zone, NewEmptyICDataArray(num_args_tested)));
12814 return result.raw(); 12846 return result.raw();
12815 } 12847 }
12816 12848
12817 12849
12818 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) { 12850 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) {
12819 const ICData& result = ICData::Handle(ICData::New( 12851 const ICData& result = ICData::Handle(ICData::New(
12820 Function::Handle(from.owner()), 12852 Function::Handle(from.Owner()),
12821 String::Handle(from.target_name()), 12853 String::Handle(from.target_name()),
12822 Array::Handle(from.arguments_descriptor()), 12854 Array::Handle(from.arguments_descriptor()),
12823 from.deopt_id(), 12855 from.deopt_id(),
12824 num_args_tested)); 12856 num_args_tested));
12825 // Copy deoptimization reasons. 12857 // Copy deoptimization reasons.
12826 result.SetDeoptReasons(from.DeoptReasons()); 12858 result.SetDeoptReasons(from.DeoptReasons());
12827 return result.raw(); 12859 return result.raw();
12828 } 12860 }
12829 12861
12830 12862
12831 RawICData* ICData::CloneDescriptor(const ICData& from) { 12863 RawICData* ICData::CloneDescriptor(const ICData& from) {
12832 Zone* zone = Thread::Current()->zone(); 12864 Zone* zone = Thread::Current()->zone();
12833 const ICData& result = ICData::Handle(ICData::NewDescriptor( 12865 const ICData& result = ICData::Handle(ICData::NewDescriptor(
12834 zone, 12866 zone,
12835 Function::Handle(zone, from.owner()), 12867 Function::Handle(zone, from.Owner()),
12836 String::Handle(zone, from.target_name()), 12868 String::Handle(zone, from.target_name()),
12837 Array::Handle(zone, from.arguments_descriptor()), 12869 Array::Handle(zone, from.arguments_descriptor()),
12838 from.deopt_id(), 12870 from.deopt_id(),
12839 from.NumArgsTested())); 12871 from.NumArgsTested()));
12840 // Preserve entry array. 12872 // Preserve entry array.
12841 result.set_ic_data_array(Array::Handle(zone, from.ic_data())); 12873 result.set_ic_data_array(Array::Handle(zone, from.ic_data()));
12842 // Copy deoptimization reasons. 12874 // Copy deoptimization reasons.
12843 result.SetDeoptReasons(from.DeoptReasons()); 12875 result.SetDeoptReasons(from.DeoptReasons());
12844 return result.raw(); 12876 return result.raw();
12845 } 12877 }
12846 12878
12847 12879
12848 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { 12880 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const {
12849 JSONObject jsobj(stream); 12881 JSONObject jsobj(stream);
12850 AddCommonObjectProperties(&jsobj, "Object", ref); 12882 AddCommonObjectProperties(&jsobj, "Object", ref);
12851 jsobj.AddServiceId(*this); 12883 jsobj.AddServiceId(*this);
12852 jsobj.AddProperty("_owner", Object::Handle(owner())); 12884 jsobj.AddProperty("_owner", Object::Handle(Owner()));
12853 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); 12885 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString());
12854 if (ref) { 12886 if (ref) {
12855 return; 12887 return;
12856 } 12888 }
12857 jsobj.AddProperty("_argumentsDescriptor", 12889 jsobj.AddProperty("_argumentsDescriptor",
12858 Object::Handle(arguments_descriptor())); 12890 Object::Handle(arguments_descriptor()));
12859 jsobj.AddProperty("_entries", Object::Handle(ic_data())); 12891 jsobj.AddProperty("_entries", Object::Handle(ic_data()));
12860 } 12892 }
12861 12893
12862 12894
(...skipping 9096 matching lines...) Expand 10 before | Expand all | Expand 10 after
21959 return tag_label.ToCString(); 21991 return tag_label.ToCString();
21960 } 21992 }
21961 21993
21962 21994
21963 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21995 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21964 Instance::PrintJSONImpl(stream, ref); 21996 Instance::PrintJSONImpl(stream, ref);
21965 } 21997 }
21966 21998
21967 21999
21968 } // namespace dart 22000 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698