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

Side by Side Diff: src/objects.cc

Issue 1626423003: Support computed properties for ES2015 Function.name (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Mostly working Created 4 years, 10 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 13292 matching lines...) Expand 10 before | Expand all | Expand 10 after
13303 13303
13304 13304
13305 Handle<String> JSFunction::GetDebugName(Handle<JSFunction> function) { 13305 Handle<String> JSFunction::GetDebugName(Handle<JSFunction> function) {
13306 Isolate* isolate = function->GetIsolate(); 13306 Isolate* isolate = function->GetIsolate();
13307 Handle<Object> name = JSReceiver::GetDataProperty( 13307 Handle<Object> name = JSReceiver::GetDataProperty(
13308 function, isolate->factory()->display_name_string()); 13308 function, isolate->factory()->display_name_string());
13309 if (name->IsString()) return Handle<String>::cast(name); 13309 if (name->IsString()) return Handle<String>::cast(name);
13310 return JSFunction::GetName(function); 13310 return JSFunction::GetName(function);
13311 } 13311 }
13312 13312
13313 void JSFunction::SetName(Handle<JSFunction> function, Handle<Name> name,
13314 Handle<String> prefix) {
13315 Isolate* isolate = function->GetIsolate();
13316 Handle<String> function_name = Name::ToFunctionName(name).ToHandleChecked();
13317 if (prefix->length() > 0) {
13318 IncrementalStringBuilder builder(isolate);
13319 builder.AppendString(prefix);
13320 builder.AppendCharacter(' ');
13321 builder.AppendString(function_name);
13322 function_name = builder.Finish().ToHandleChecked();
13323 }
13324 JSObject::DefinePropertyOrElementIgnoreAttributes(
13325 function, isolate->factory()->name_string(), function_name,
13326 static_cast<PropertyAttributes>(DONT_ENUM | READ_ONLY))
13327 .ToHandleChecked();
13328 }
13313 13329
13314 namespace { 13330 namespace {
13315 13331
13316 char const kNativeCodeSource[] = "function () { [native code] }"; 13332 char const kNativeCodeSource[] = "function () { [native code] }";
13317 13333
13318 13334
13319 Handle<String> NativeCodeFunctionSourceString( 13335 Handle<String> NativeCodeFunctionSourceString(
13320 Handle<SharedFunctionInfo> shared_info) { 13336 Handle<SharedFunctionInfo> shared_info) {
13321 Isolate* const isolate = shared_info->GetIsolate(); 13337 Isolate* const isolate = shared_info->GetIsolate();
13322 if (shared_info->name()->IsString()) { 13338 if (shared_info->name()->IsString()) {
(...skipping 6466 matching lines...) Expand 10 before | Expand all | Expand 10 after
19789 if (cell->value() != *new_value) { 19805 if (cell->value() != *new_value) {
19790 cell->set_value(*new_value); 19806 cell->set_value(*new_value);
19791 Isolate* isolate = cell->GetIsolate(); 19807 Isolate* isolate = cell->GetIsolate();
19792 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19808 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19793 isolate, DependentCode::kPropertyCellChangedGroup); 19809 isolate, DependentCode::kPropertyCellChangedGroup);
19794 } 19810 }
19795 } 19811 }
19796 19812
19797 } // namespace internal 19813 } // namespace internal
19798 } // namespace v8 19814 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698