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

Side by Side Diff: src/type-info.cc

Issue 254623002: Simplify feedback vector creation and store in SharedFunctionInfo. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Code comments Created 6 years, 7 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 | « src/type-info.h ('k') | src/typing.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 25 matching lines...) Expand all
36 #include "type-info.h" 36 #include "type-info.h"
37 37
38 #include "ic-inl.h" 38 #include "ic-inl.h"
39 #include "objects-inl.h" 39 #include "objects-inl.h"
40 40
41 namespace v8 { 41 namespace v8 {
42 namespace internal { 42 namespace internal {
43 43
44 44
45 TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code, 45 TypeFeedbackOracle::TypeFeedbackOracle(Handle<Code> code,
46 Handle<FixedArray> feedback_vector,
46 Handle<Context> native_context, 47 Handle<Context> native_context,
47 Zone* zone) 48 Zone* zone)
48 : native_context_(native_context), 49 : native_context_(native_context),
49 zone_(zone) { 50 zone_(zone) {
50 Object* raw_info = code->type_feedback_info();
51 if (raw_info->IsTypeFeedbackInfo()) {
52 feedback_vector_ = Handle<FixedArray>(TypeFeedbackInfo::cast(raw_info)->
53 feedback_vector());
54 }
55
56 BuildDictionary(code); 51 BuildDictionary(code);
57 ASSERT(dictionary_->IsDictionary()); 52 ASSERT(dictionary_->IsDictionary());
53 // We make a copy of the feedback vector because a GC could clear
54 // the type feedback info contained therein.
55 // TODO(mvstanton): revisit the decision to copy when we weakly
56 // traverse the feedback vector at GC time.
57 feedback_vector_ = isolate()->factory()->CopyFixedArray(feedback_vector);
58 } 58 }
59 59
60 60
61 static uint32_t IdToKey(TypeFeedbackId ast_id) { 61 static uint32_t IdToKey(TypeFeedbackId ast_id) {
62 return static_cast<uint32_t>(ast_id.ToInt()); 62 return static_cast<uint32_t>(ast_id.ToInt());
63 } 63 }
64 64
65 65
66 Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) { 66 Handle<Object> TypeFeedbackOracle::GetInfo(TypeFeedbackId ast_id) {
67 int entry = dictionary_->FindEntry(IdToKey(ast_id)); 67 int entry = dictionary_->FindEntry(IdToKey(ast_id));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 bool TypeFeedbackOracle::CallNewIsMonomorphic(int slot) { 129 bool TypeFeedbackOracle::CallNewIsMonomorphic(int slot) {
130 Handle<Object> info = GetInfo(slot); 130 Handle<Object> info = GetInfo(slot);
131 return FLAG_pretenuring_call_new 131 return FLAG_pretenuring_call_new
132 ? info->IsJSFunction() 132 ? info->IsJSFunction()
133 : info->IsAllocationSite() || info->IsJSFunction(); 133 : info->IsAllocationSite() || info->IsJSFunction();
134 } 134 }
135 135
136 136
137 byte TypeFeedbackOracle::ForInType(int feedback_vector_slot) { 137 byte TypeFeedbackOracle::ForInType(int feedback_vector_slot) {
138 Handle<Object> value = GetInfo(feedback_vector_slot); 138 Handle<Object> value = GetInfo(feedback_vector_slot);
139 return value->IsSmi() && 139 return value.is_identical_to(
140 Smi::cast(*value)->value() == TypeFeedbackInfo::kForInFastCaseMarker 140 TypeFeedbackInfo::UninitializedSentinel(isolate()))
141 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN; 141 ? ForInStatement::FAST_FOR_IN : ForInStatement::SLOW_FOR_IN;
142 } 142 }
143 143
144 144
145 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode( 145 KeyedAccessStoreMode TypeFeedbackOracle::GetStoreMode(
146 TypeFeedbackId ast_id) { 146 TypeFeedbackId ast_id) {
147 Handle<Object> maybe_code = GetInfo(ast_id); 147 Handle<Object> maybe_code = GetInfo(ast_id);
148 if (maybe_code->IsCode()) { 148 if (maybe_code->IsCode()) {
149 Handle<Code> code = Handle<Code>::cast(maybe_code); 149 Handle<Code> code = Handle<Code>::cast(maybe_code);
150 if (code->kind() == Code::KEYED_STORE_IC) { 150 if (code->kind() == Code::KEYED_STORE_IC) {
151 return KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state()); 151 return KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state());
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 UnseededNumberDictionary::kNotFound); 493 UnseededNumberDictionary::kNotFound);
494 // Dictionary has been allocated with sufficient size for all elements. 494 // Dictionary has been allocated with sufficient size for all elements.
495 DisallowHeapAllocation no_need_to_resize_dictionary; 495 DisallowHeapAllocation no_need_to_resize_dictionary;
496 HandleScope scope(isolate()); 496 HandleScope scope(isolate());
497 USE(UnseededNumberDictionary::AtNumberPut( 497 USE(UnseededNumberDictionary::AtNumberPut(
498 dictionary_, IdToKey(ast_id), handle(target, isolate()))); 498 dictionary_, IdToKey(ast_id), handle(target, isolate())));
499 } 499 }
500 500
501 501
502 } } // namespace v8::internal 502 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-info.h ('k') | src/typing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698