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

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

Issue 311963002: In class Function replace current code field with current instruction field, that way we save one l… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('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 4909 matching lines...) Expand 10 before | Expand all | Expand 10 after
4920 void PatchClass::set_source_class(const Class& value) const { 4920 void PatchClass::set_source_class(const Class& value) const {
4921 StorePointer(&raw_ptr()->source_class_, value.raw()); 4921 StorePointer(&raw_ptr()->source_class_, value.raw());
4922 } 4922 }
4923 4923
4924 4924
4925 bool Function::HasBreakpoint() const { 4925 bool Function::HasBreakpoint() const {
4926 return Isolate::Current()->debugger()->HasBreakpoint(*this); 4926 return Isolate::Current()->debugger()->HasBreakpoint(*this);
4927 } 4927 }
4928 4928
4929 4929
4930 void Function::set_code(const Code& value) const { 4930 void Function::SetInstructions(const Code& value) const {
4931 StorePointer(&raw_ptr()->code_, value.raw()); 4931 StorePointer(&raw_ptr()->instructions_, value.instructions());
4932 } 4932 }
4933 4933
4934 void Function::AttachCode(const Code& value) const { 4934 void Function::AttachCode(const Code& value) const {
4935 set_code(value); 4935 SetInstructions(value);
4936 ASSERT(Function::Handle(value.function()).IsNull() || 4936 ASSERT(Function::Handle(value.function()).IsNull() ||
4937 (value.function() == this->raw())); 4937 (value.function() == this->raw()));
4938 value.set_owner(*this); 4938 value.set_owner(*this);
4939 } 4939 }
4940 4940
4941 4941
4942 bool Function::HasCode() const { 4942 bool Function::HasCode() const {
4943 ASSERT(raw_ptr()->code_ != Code::null()); 4943 ASSERT(raw_ptr()->instructions_ != Instructions::null());
4944 return raw_ptr()->code_ != StubCode::LazyCompile_entry()->code(); 4944 return raw_ptr()->instructions_ !=
4945 StubCode::LazyCompile_entry()->code()->ptr()->instructions_;
4945 } 4946 }
4946 4947
4947 4948
4948 void Function::ClearCode() const { 4949 void Function::ClearCode() const {
4949 StorePointer(&raw_ptr()->code_, StubCode::LazyCompile_entry()->code());
4950 StorePointer(&raw_ptr()->unoptimized_code_, Code::null()); 4950 StorePointer(&raw_ptr()->unoptimized_code_, Code::null());
4951 StorePointer(&raw_ptr()->instructions_,
4952 Code::Handle(StubCode::LazyCompile_entry()->code()).instructions());
4951 } 4953 }
4952 4954
4953 4955
4954 void Function::SwitchToUnoptimizedCode() const { 4956 void Function::SwitchToUnoptimizedCode() const {
4955 ASSERT(HasOptimizedCode()); 4957 ASSERT(HasOptimizedCode());
4956 const Code& current_code = Code::Handle(CurrentCode()); 4958 const Code& current_code = Code::Handle(CurrentCode());
4957 4959
4958 if (FLAG_trace_disabling_optimized_code) { 4960 if (FLAG_trace_disabling_optimized_code) {
4959 OS::Print("Disabling optimized code: '%s' entry: %#" Px "\n", 4961 OS::Print("Disabling optimized code: '%s' entry: %#" Px "\n",
4960 ToFullyQualifiedCString(), 4962 ToFullyQualifiedCString(),
(...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
5969 result.set_end_token_pos(token_pos); 5971 result.set_end_token_pos(token_pos);
5970 result.set_num_fixed_parameters(0); 5972 result.set_num_fixed_parameters(0);
5971 result.set_num_optional_parameters(0); 5973 result.set_num_optional_parameters(0);
5972 result.set_usage_counter(0); 5974 result.set_usage_counter(0);
5973 result.set_deoptimization_counter(0); 5975 result.set_deoptimization_counter(0);
5974 result.set_optimized_instruction_count(0); 5976 result.set_optimized_instruction_count(0);
5975 result.set_optimized_call_site_count(0); 5977 result.set_optimized_call_site_count(0);
5976 result.set_is_optimizable(is_native ? false : true); 5978 result.set_is_optimizable(is_native ? false : true);
5977 result.set_is_inlinable(true); 5979 result.set_is_inlinable(true);
5978 result.set_allows_hoisting_check_class(true); 5980 result.set_allows_hoisting_check_class(true);
5979 result.set_code(Code::Handle(StubCode::LazyCompile_entry()->code())); 5981 result.SetInstructions(Code::Handle(StubCode::LazyCompile_entry()->code()));
5980 if (kind == RawFunction::kClosureFunction) { 5982 if (kind == RawFunction::kClosureFunction) {
5981 const ClosureData& data = ClosureData::Handle(ClosureData::New()); 5983 const ClosureData& data = ClosureData::Handle(ClosureData::New());
5982 result.set_data(data); 5984 result.set_data(data);
5983 } 5985 }
5984 5986
5985 return result.raw(); 5987 return result.raw();
5986 } 5988 }
5987 5989
5988 5990
5989 RawFunction* Function::Clone(const Class& new_owner) const { 5991 RawFunction* Function::Clone(const Class& new_owner) const {
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
6294 const Object& obj = Object::Handle(raw_ptr()->owner_); 6296 const Object& obj = Object::Handle(raw_ptr()->owner_);
6295 if (obj.IsClass()) { 6297 if (obj.IsClass()) {
6296 return Class::Cast(obj).script(); 6298 return Class::Cast(obj).script();
6297 } 6299 }
6298 ASSERT(obj.IsPatchClass()); 6300 ASSERT(obj.IsPatchClass());
6299 return PatchClass::Cast(obj).Script(); 6301 return PatchClass::Cast(obj).Script();
6300 } 6302 }
6301 6303
6302 6304
6303 bool Function::HasOptimizedCode() const { 6305 bool Function::HasOptimizedCode() const {
6304 return HasCode() && Code::Handle(raw_ptr()->code_).is_optimized(); 6306 return HasCode() && Code::Handle(Instructions::Handle(
6307 raw_ptr()->instructions_).code()).is_optimized();
6305 } 6308 }
6306 6309
6307 6310
6308 RawString* Function::PrettyName() const { 6311 RawString* Function::PrettyName() const {
6309 const String& str = String::Handle(name()); 6312 const String& str = String::Handle(name());
6310 return String::IdentifierPrettyName(str); 6313 return String::IdentifierPrettyName(str);
6311 } 6314 }
6312 6315
6313 6316
6314 RawString* Function::UserVisibleName() const { 6317 RawString* Function::UserVisibleName() const {
(...skipping 12665 matching lines...) Expand 10 before | Expand all | Expand 10 after
18980 return tag_label.ToCString(); 18983 return tag_label.ToCString();
18981 } 18984 }
18982 18985
18983 18986
18984 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 18987 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
18985 Instance::PrintJSONImpl(stream, ref); 18988 Instance::PrintJSONImpl(stream, ref);
18986 } 18989 }
18987 18990
18988 18991
18989 } // namespace dart 18992 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698