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

Side by Side Diff: src/accessors.cc

Issue 2396353002: Revert "Add Smi::Zero and replace all Smi::FromInt(0) calls" (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | src/api.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/accessors.h" 5 #include "src/accessors.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/contexts.h" 8 #include "src/contexts.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 731
732 void Accessors::FunctionLengthGetter( 732 void Accessors::FunctionLengthGetter(
733 v8::Local<v8::Name> name, 733 v8::Local<v8::Name> name,
734 const v8::PropertyCallbackInfo<v8::Value>& info) { 734 const v8::PropertyCallbackInfo<v8::Value>& info) {
735 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 735 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
736 HandleScope scope(isolate); 736 HandleScope scope(isolate);
737 Handle<JSFunction> function = 737 Handle<JSFunction> function =
738 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder())); 738 Handle<JSFunction>::cast(Utils::OpenHandle(*info.Holder()));
739 Handle<Object> result; 739 Handle<Object> result;
740 if (!JSFunction::GetLength(isolate, function).ToHandle(&result)) { 740 if (!JSFunction::GetLength(isolate, function).ToHandle(&result)) {
741 result = handle(Smi::kZero, isolate); 741 result = handle(Smi::FromInt(0), isolate);
742 isolate->OptionalRescheduleException(false); 742 isolate->OptionalRescheduleException(false);
743 } 743 }
744 744
745 info.GetReturnValue().Set(Utils::ToLocal(result)); 745 info.GetReturnValue().Set(Utils::ToLocal(result));
746 } 746 }
747 747
748 Handle<AccessorInfo> Accessors::FunctionLengthInfo( 748 Handle<AccessorInfo> Accessors::FunctionLengthInfo(
749 Isolate* isolate, PropertyAttributes attributes) { 749 Isolate* isolate, PropertyAttributes attributes) {
750 return MakeAccessor(isolate, isolate->factory()->length_string(), 750 return MakeAccessor(isolate, isolate->factory()->length_string(),
751 &FunctionLengthGetter, &ReconfigureToDataProperty, 751 &FunctionLengthGetter, &ReconfigureToDataProperty,
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { 1065 v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
1066 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate()); 1066 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
1067 HandleScope scope(isolate); 1067 HandleScope scope(isolate);
1068 Handle<JSBoundFunction> function = 1068 Handle<JSBoundFunction> function =
1069 Handle<JSBoundFunction>::cast(Utils::OpenHandle(*info.Holder())); 1069 Handle<JSBoundFunction>::cast(Utils::OpenHandle(*info.Holder()));
1070 1070
1071 Handle<Smi> target_length; 1071 Handle<Smi> target_length;
1072 Handle<JSFunction> target(JSFunction::cast(function->bound_target_function()), 1072 Handle<JSFunction> target(JSFunction::cast(function->bound_target_function()),
1073 isolate); 1073 isolate);
1074 if (!JSFunction::GetLength(isolate, target).ToHandle(&target_length)) { 1074 if (!JSFunction::GetLength(isolate, target).ToHandle(&target_length)) {
1075 target_length = handle(Smi::kZero, isolate); 1075 target_length = handle(Smi::FromInt(0), isolate);
1076 isolate->OptionalRescheduleException(false); 1076 isolate->OptionalRescheduleException(false);
1077 return; 1077 return;
1078 } 1078 }
1079 1079
1080 int bound_length = function->bound_arguments()->length(); 1080 int bound_length = function->bound_arguments()->length();
1081 int length = Max(0, target_length->value() - bound_length); 1081 int length = Max(0, target_length->value() - bound_length);
1082 1082
1083 Handle<Object> result(Smi::FromInt(length), isolate); 1083 Handle<Object> result(Smi::FromInt(length), isolate);
1084 info.GetReturnValue().Set(Utils::ToLocal(result)); 1084 info.GetReturnValue().Set(Utils::ToLocal(result));
1085 } 1085 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate, 1227 Handle<AccessorInfo> Accessors::ErrorStackInfo(Isolate* isolate,
1228 PropertyAttributes attributes) { 1228 PropertyAttributes attributes) {
1229 Handle<AccessorInfo> info = 1229 Handle<AccessorInfo> info =
1230 MakeAccessor(isolate, isolate->factory()->stack_string(), 1230 MakeAccessor(isolate, isolate->factory()->stack_string(),
1231 &ErrorStackGetter, &ErrorStackSetter, attributes); 1231 &ErrorStackGetter, &ErrorStackSetter, attributes);
1232 return info; 1232 return info;
1233 } 1233 }
1234 1234
1235 } // namespace internal 1235 } // namespace internal
1236 } // namespace v8 1236 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698