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

Side by Side Diff: src/objects.cc

Issue 1823033002: [compiler] Move PassesFilter onto SharedFunctionInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 13122 matching lines...) Expand 10 before | Expand all | Expand 10 after
13133 return map; 13133 return map;
13134 } 13134 }
13135 13135
13136 13136
13137 void JSFunction::PrintName(FILE* out) { 13137 void JSFunction::PrintName(FILE* out) {
13138 base::SmartArrayPointer<char> name = shared()->DebugName()->ToCString(); 13138 base::SmartArrayPointer<char> name = shared()->DebugName()->ToCString();
13139 PrintF(out, "%s", name.get()); 13139 PrintF(out, "%s", name.get());
13140 } 13140 }
13141 13141
13142 13142
13143 // The filter is a pattern that matches function names in this way:
13144 // "*" all; the default
13145 // "-" all but the top-level function
13146 // "-name" all but the function "name"
13147 // "" only the top-level function
13148 // "name" only the function "name"
13149 // "name*" only functions starting with "name"
13150 // "~" none; the tilde is not an identifier
13151 bool JSFunction::PassesFilter(const char* raw_filter) {
13152 if (*raw_filter == '*') return true;
13153 String* name = shared()->DebugName();
13154 Vector<const char> filter = CStrVector(raw_filter);
13155 if (filter.length() == 0) return name->length() == 0;
13156 if (filter[0] == '-') {
13157 // Negative filter.
13158 if (filter.length() == 1) {
13159 return (name->length() != 0);
13160 } else if (name->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) {
13161 return false;
13162 }
13163 if (filter[filter.length() - 1] == '*' &&
13164 name->IsUtf8EqualTo(filter.SubVector(1, filter.length() - 1), true)) {
13165 return false;
13166 }
13167 return true;
13168
13169 } else if (name->IsUtf8EqualTo(filter)) {
13170 return true;
13171 }
13172 if (filter[filter.length() - 1] == '*' &&
13173 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
13174 return true;
13175 }
13176 return false;
13177 }
13178
13179
13180 Handle<String> JSFunction::GetName(Handle<JSFunction> function) { 13143 Handle<String> JSFunction::GetName(Handle<JSFunction> function) {
13181 Isolate* isolate = function->GetIsolate(); 13144 Isolate* isolate = function->GetIsolate();
13182 Handle<Object> name = 13145 Handle<Object> name =
13183 JSReceiver::GetDataProperty(function, isolate->factory()->name_string()); 13146 JSReceiver::GetDataProperty(function, isolate->factory()->name_string());
13184 if (name->IsString()) return Handle<String>::cast(name); 13147 if (name->IsString()) return Handle<String>::cast(name);
13185 return handle(function->shared()->DebugName(), isolate); 13148 return handle(function->shared()->DebugName(), isolate);
13186 } 13149 }
13187 13150
13188 13151
13189 Handle<String> JSFunction::GetDebugName(Handle<JSFunction> function) { 13152 Handle<String> JSFunction::GetDebugName(Handle<JSFunction> function) {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
13535 shared->set_script(*script_object); 13498 shared->set_script(*script_object);
13536 } 13499 }
13537 13500
13538 13501
13539 String* SharedFunctionInfo::DebugName() { 13502 String* SharedFunctionInfo::DebugName() {
13540 Object* n = name(); 13503 Object* n = name();
13541 if (!n->IsString() || String::cast(n)->length() == 0) return inferred_name(); 13504 if (!n->IsString() || String::cast(n)->length() == 0) return inferred_name();
13542 return String::cast(n); 13505 return String::cast(n);
13543 } 13506 }
13544 13507
13508 // The filter is a pattern that matches function names in this way:
13509 // "*" all; the default
13510 // "-" all but the top-level function
13511 // "-name" all but the function "name"
13512 // "" only the top-level function
13513 // "name" only the function "name"
13514 // "name*" only functions starting with "name"
13515 // "~" none; the tilde is not an identifier
13516 bool SharedFunctionInfo::PassesFilter(const char* raw_filter) {
13517 if (*raw_filter == '*') return true;
13518 String* name = DebugName();
Michael Starzinger 2016/03/22 09:06:31 The only change inside the function was this one l
Jakob Kummerow 2016/03/22 09:32:11 Acknowledged.
13519 Vector<const char> filter = CStrVector(raw_filter);
13520 if (filter.length() == 0) return name->length() == 0;
13521 if (filter[0] == '-') {
13522 // Negative filter.
13523 if (filter.length() == 1) {
13524 return (name->length() != 0);
13525 } else if (name->IsUtf8EqualTo(filter.SubVector(1, filter.length()))) {
13526 return false;
13527 }
13528 if (filter[filter.length() - 1] == '*' &&
13529 name->IsUtf8EqualTo(filter.SubVector(1, filter.length() - 1), true)) {
13530 return false;
13531 }
13532 return true;
13533
13534 } else if (name->IsUtf8EqualTo(filter)) {
13535 return true;
13536 }
13537 if (filter[filter.length() - 1] == '*' &&
13538 name->IsUtf8EqualTo(filter.SubVector(0, filter.length() - 1), true)) {
13539 return true;
13540 }
13541 return false;
13542 }
13545 13543
13546 bool SharedFunctionInfo::HasSourceCode() const { 13544 bool SharedFunctionInfo::HasSourceCode() const {
13547 return !script()->IsUndefined() && 13545 return !script()->IsUndefined() &&
13548 !reinterpret_cast<Script*>(script())->source()->IsUndefined(); 13546 !reinterpret_cast<Script*>(script())->source()->IsUndefined();
13549 } 13547 }
13550 13548
13551 13549
13552 Handle<Object> SharedFunctionInfo::GetSourceCode() { 13550 Handle<Object> SharedFunctionInfo::GetSourceCode() {
13553 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value(); 13551 if (!HasSourceCode()) return GetIsolate()->factory()->undefined_value();
13554 Handle<String> source(String::cast(Script::cast(script())->source())); 13552 Handle<String> source(String::cast(Script::cast(script())->source()));
(...skipping 6193 matching lines...) Expand 10 before | Expand all | Expand 10 after
19748 if (cell->value() != *new_value) { 19746 if (cell->value() != *new_value) {
19749 cell->set_value(*new_value); 19747 cell->set_value(*new_value);
19750 Isolate* isolate = cell->GetIsolate(); 19748 Isolate* isolate = cell->GetIsolate();
19751 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19749 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19752 isolate, DependentCode::kPropertyCellChangedGroup); 19750 isolate, DependentCode::kPropertyCellChangedGroup);
19753 } 19751 }
19754 } 19752 }
19755 19753
19756 } // namespace internal 19754 } // namespace internal
19757 } // namespace v8 19755 } // namespace v8
OLDNEW
« src/compiler.cc ('K') | « src/objects.h ('k') | src/runtime-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698