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

Side by Side Diff: src/objects.cc

Issue 1988023004: Speed up common ObjectProtoToString cases (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: restore bootstrapper Created 4 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
« no previous file with comments | « src/heap-symbols.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 15228 matching lines...) Expand 10 before | Expand all | Expand 10 after
15239 } else { 15239 } else {
15240 DCHECK(!is_api_object); 15240 DCHECK(!is_api_object);
15241 } 15241 }
15242 } 15242 }
15243 #endif 15243 #endif
15244 return is_api_object; 15244 return is_api_object;
15245 } 15245 }
15246 15246
15247 MaybeHandle<String> Object::ObjectProtoToString(Isolate* isolate, 15247 MaybeHandle<String> Object::ObjectProtoToString(Isolate* isolate,
15248 Handle<Object> object) { 15248 Handle<Object> object) {
15249 if (object->IsUndefined()) return isolate->factory()->undefined_to_string(); 15249 if (*object == isolate->heap()->undefined_value()) {
15250 if (object->IsNull()) return isolate->factory()->null_to_string(); 15250 return isolate->factory()->undefined_to_string();
15251 }
15252 if (*object == isolate->heap()->null_value()) {
15253 return isolate->factory()->null_to_string();
15254 }
15251 15255
15252 Handle<JSReceiver> receiver = 15256 Handle<JSReceiver> receiver =
15253 Object::ToObject(isolate, object).ToHandleChecked(); 15257 Object::ToObject(isolate, object).ToHandleChecked();
15254 15258
15255 Handle<String> tag; 15259 Handle<String> tag;
15256 Handle<Object> to_string_tag; 15260 Handle<Object> to_string_tag;
15257 ASSIGN_RETURN_ON_EXCEPTION( 15261 ASSIGN_RETURN_ON_EXCEPTION(
15258 isolate, to_string_tag, 15262 isolate, to_string_tag,
15259 JSReceiver::GetProperty(receiver, 15263 JSReceiver::GetProperty(receiver,
15260 isolate->factory()->to_string_tag_symbol()), 15264 isolate->factory()->to_string_tag_symbol()),
15261 String); 15265 String);
15262 if (to_string_tag->IsString()) { 15266 if (to_string_tag->IsString()) {
15263 tag = Handle<String>::cast(to_string_tag); 15267 tag = Handle<String>::cast(to_string_tag);
15264 } 15268 }
15265 15269
15266 if (tag.is_null()) { 15270 if (tag.is_null()) {
15267 ASSIGN_RETURN_ON_EXCEPTION(isolate, tag, 15271 ASSIGN_RETURN_ON_EXCEPTION(isolate, tag,
15268 JSReceiver::BuiltinStringTag(receiver), String); 15272 JSReceiver::BuiltinStringTag(receiver), String);
15269 } 15273 }
15270 15274
15275 if (*tag == isolate->heap()->Object_string()) {
15276 return isolate->factory()->object_to_string();
15277 }
15278 if (*tag == isolate->heap()->String_string()) {
15279 return isolate->factory()->string_to_string();
15280 }
15281 if (*tag == isolate->heap()->Array_string()) {
15282 return isolate->factory()->array_to_string();
15283 }
15284 if (*tag == isolate->heap()->Function_string()) {
15285 return isolate->factory()->function_to_string();
15286 }
15271 IncrementalStringBuilder builder(isolate); 15287 IncrementalStringBuilder builder(isolate);
15272 builder.AppendCString("[object "); 15288 builder.AppendCString("[object ");
15273 builder.AppendString(tag); 15289 builder.AppendString(tag);
15274 builder.AppendCharacter(']'); 15290 builder.AppendCharacter(']');
15275 return builder.Finish(); 15291 return builder.Finish();
15276 } 15292 }
15277 15293
15278 15294
15279 const char* Symbol::PrivateSymbolToName() const { 15295 const char* Symbol::PrivateSymbolToName() const {
15280 Heap* heap = GetIsolate()->heap(); 15296 Heap* heap = GetIsolate()->heap();
(...skipping 3101 matching lines...) Expand 10 before | Expand all | Expand 10 after
18382 if (cell->value() != *new_value) { 18398 if (cell->value() != *new_value) {
18383 cell->set_value(*new_value); 18399 cell->set_value(*new_value);
18384 Isolate* isolate = cell->GetIsolate(); 18400 Isolate* isolate = cell->GetIsolate();
18385 cell->dependent_code()->DeoptimizeDependentCodeGroup( 18401 cell->dependent_code()->DeoptimizeDependentCodeGroup(
18386 isolate, DependentCode::kPropertyCellChangedGroup); 18402 isolate, DependentCode::kPropertyCellChangedGroup);
18387 } 18403 }
18388 } 18404 }
18389 18405
18390 } // namespace internal 18406 } // namespace internal
18391 } // namespace v8 18407 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap-symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698