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

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: remove flag 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
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.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 (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 if (IsNull()) {
12195 return ICData::null();
12196 }
12197 Object& obj = Object::Handle(raw_ptr()->owner_);
12198 if (obj.IsFunction()) {
12199 return this->raw();
12200 } else {
12201 return ICData::RawCast(obj.raw());
12202 }
12203 }
12204
12205
12206 void ICData::SetOriginal(const ICData& value) const {
12207 ASSERT(value.IsOriginal());
12208 ASSERT(!value.IsNull());
12209 StorePointer(&raw_ptr()->owner_, reinterpret_cast<RawObject*>(value.raw()));
12210 }
12211
12212
12179 void ICData::set_owner(const Function& value) const { 12213 void ICData::set_owner(const Function& value) const {
12180 ASSERT(!value.IsNull()); 12214 ASSERT(!value.IsNull());
12181 StorePointer(&raw_ptr()->owner_, value.raw()); 12215 StorePointer(&raw_ptr()->owner_, reinterpret_cast<RawObject*>(value.raw()));
12182 } 12216 }
12183 12217
12184 12218
12185 void ICData::set_target_name(const String& value) const { 12219 void ICData::set_target_name(const String& value) const {
12186 ASSERT(!value.IsNull()); 12220 ASSERT(!value.IsNull());
12187 StorePointer(&raw_ptr()->target_name_, value.raw()); 12221 StorePointer(&raw_ptr()->target_name_, value.raw());
12188 } 12222 }
12189 12223
12190 12224
12191 void ICData::set_arguments_descriptor(const Array& value) const { 12225 void ICData::set_arguments_descriptor(const Array& value) const {
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
12810 deopt_id, 12844 deopt_id,
12811 num_args_tested)); 12845 num_args_tested));
12812 result.set_ic_data_array( 12846 result.set_ic_data_array(
12813 Array::Handle(zone, NewEmptyICDataArray(num_args_tested))); 12847 Array::Handle(zone, NewEmptyICDataArray(num_args_tested)));
12814 return result.raw(); 12848 return result.raw();
12815 } 12849 }
12816 12850
12817 12851
12818 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) { 12852 RawICData* ICData::NewFrom(const ICData& from, intptr_t num_args_tested) {
12819 const ICData& result = ICData::Handle(ICData::New( 12853 const ICData& result = ICData::Handle(ICData::New(
12820 Function::Handle(from.owner()), 12854 Function::Handle(from.Owner()),
12821 String::Handle(from.target_name()), 12855 String::Handle(from.target_name()),
12822 Array::Handle(from.arguments_descriptor()), 12856 Array::Handle(from.arguments_descriptor()),
12823 from.deopt_id(), 12857 from.deopt_id(),
12824 num_args_tested)); 12858 num_args_tested));
12825 // Copy deoptimization reasons. 12859 // Copy deoptimization reasons.
12826 result.SetDeoptReasons(from.DeoptReasons()); 12860 result.SetDeoptReasons(from.DeoptReasons());
12827 return result.raw(); 12861 return result.raw();
12828 } 12862 }
12829 12863
12830 12864
12831 RawICData* ICData::CloneDescriptor(const ICData& from) { 12865 RawICData* ICData::CloneDescriptor(const ICData& from) {
12832 Zone* zone = Thread::Current()->zone(); 12866 Zone* zone = Thread::Current()->zone();
12833 const ICData& result = ICData::Handle(ICData::NewDescriptor( 12867 const ICData& result = ICData::Handle(ICData::NewDescriptor(
12834 zone, 12868 zone,
12835 Function::Handle(zone, from.owner()), 12869 Function::Handle(zone, from.Owner()),
12836 String::Handle(zone, from.target_name()), 12870 String::Handle(zone, from.target_name()),
12837 Array::Handle(zone, from.arguments_descriptor()), 12871 Array::Handle(zone, from.arguments_descriptor()),
12838 from.deopt_id(), 12872 from.deopt_id(),
12839 from.NumArgsTested())); 12873 from.NumArgsTested()));
12840 // Preserve entry array. 12874 // Preserve entry array.
12841 result.set_ic_data_array(Array::Handle(zone, from.ic_data())); 12875 result.set_ic_data_array(Array::Handle(zone, from.ic_data()));
12842 // Copy deoptimization reasons. 12876 // Copy deoptimization reasons.
12843 result.SetDeoptReasons(from.DeoptReasons()); 12877 result.SetDeoptReasons(from.DeoptReasons());
12844 return result.raw(); 12878 return result.raw();
12845 } 12879 }
12846 12880
12847 12881
12848 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const { 12882 void ICData::PrintJSONImpl(JSONStream* stream, bool ref) const {
12849 JSONObject jsobj(stream); 12883 JSONObject jsobj(stream);
12850 AddCommonObjectProperties(&jsobj, "Object", ref); 12884 AddCommonObjectProperties(&jsobj, "Object", ref);
12851 jsobj.AddServiceId(*this); 12885 jsobj.AddServiceId(*this);
12852 jsobj.AddProperty("_owner", Object::Handle(owner())); 12886 jsobj.AddProperty("_owner", Object::Handle(Owner()));
12853 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString()); 12887 jsobj.AddProperty("_selector", String::Handle(target_name()).ToCString());
12854 if (ref) { 12888 if (ref) {
12855 return; 12889 return;
12856 } 12890 }
12857 jsobj.AddProperty("_argumentsDescriptor", 12891 jsobj.AddProperty("_argumentsDescriptor",
12858 Object::Handle(arguments_descriptor())); 12892 Object::Handle(arguments_descriptor()));
12859 jsobj.AddProperty("_entries", Object::Handle(ic_data())); 12893 jsobj.AddProperty("_entries", Object::Handle(ic_data()));
12860 } 12894 }
12861 12895
12862 12896
(...skipping 9096 matching lines...) Expand 10 before | Expand all | Expand 10 after
21959 return tag_label.ToCString(); 21993 return tag_label.ToCString();
21960 } 21994 }
21961 21995
21962 21996
21963 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21997 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21964 Instance::PrintJSONImpl(stream, ref); 21998 Instance::PrintJSONImpl(stream, ref);
21965 } 21999 }
21966 22000
21967 22001
21968 } // namespace dart 22002 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698