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

Side by Side Diff: src/runtime.cc

Issue 282493005: Harden more runtime functions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: s/0x000000000/0x0/ 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/objects-inl.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 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "v8.h" 8 #include "v8.h"
9 9
10 #include "accessors.h" 10 #include "accessors.h"
(...skipping 3012 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 return isolate->heap()->undefined_value(); 3023 return isolate->heap()->undefined_value();
3024 } 3024 }
3025 3025
3026 3026
3027 RUNTIME_FUNCTION(Runtime_FunctionSetLength) { 3027 RUNTIME_FUNCTION(Runtime_FunctionSetLength) {
3028 SealHandleScope shs(isolate); 3028 SealHandleScope shs(isolate);
3029 ASSERT(args.length() == 2); 3029 ASSERT(args.length() == 2);
3030 3030
3031 CONVERT_ARG_CHECKED(JSFunction, fun, 0); 3031 CONVERT_ARG_CHECKED(JSFunction, fun, 0);
3032 CONVERT_SMI_ARG_CHECKED(length, 1); 3032 CONVERT_SMI_ARG_CHECKED(length, 1);
3033 RUNTIME_ASSERT((length & 0xC0000000) == 0xC0000000 ||
3034 (length & 0xC0000000) == 0x0);
3033 fun->shared()->set_length(length); 3035 fun->shared()->set_length(length);
3034 return isolate->heap()->undefined_value(); 3036 return isolate->heap()->undefined_value();
3035 } 3037 }
3036 3038
3037 3039
3038 RUNTIME_FUNCTION(Runtime_FunctionSetPrototype) { 3040 RUNTIME_FUNCTION(Runtime_FunctionSetPrototype) {
3039 HandleScope scope(isolate); 3041 HandleScope scope(isolate);
3040 ASSERT(args.length() == 2); 3042 ASSERT(args.length() == 2);
3041 3043
3042 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 3044 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after
4875 4877
4876 RUNTIME_FUNCTION(Runtime_NumberToFixed) { 4878 RUNTIME_FUNCTION(Runtime_NumberToFixed) {
4877 HandleScope scope(isolate); 4879 HandleScope scope(isolate);
4878 ASSERT(args.length() == 2); 4880 ASSERT(args.length() == 2);
4879 4881
4880 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 4882 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
4881 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); 4883 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
4882 int f = FastD2IChecked(f_number); 4884 int f = FastD2IChecked(f_number);
4883 // See DoubleToFixedCString for these constants: 4885 // See DoubleToFixedCString for these constants:
4884 RUNTIME_ASSERT(f >= 0 && f <= 20); 4886 RUNTIME_ASSERT(f >= 0 && f <= 20);
4887 RUNTIME_ASSERT(!Double(value).IsSpecial());
4885 char* str = DoubleToFixedCString(value, f); 4888 char* str = DoubleToFixedCString(value, f);
4886 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); 4889 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str);
4887 DeleteArray(str); 4890 DeleteArray(str);
4888 return *result; 4891 return *result;
4889 } 4892 }
4890 4893
4891 4894
4892 RUNTIME_FUNCTION(Runtime_NumberToExponential) { 4895 RUNTIME_FUNCTION(Runtime_NumberToExponential) {
4893 HandleScope scope(isolate); 4896 HandleScope scope(isolate);
4894 ASSERT(args.length() == 2); 4897 ASSERT(args.length() == 2);
4895 4898
4896 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 4899 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
4897 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); 4900 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
4898 int f = FastD2IChecked(f_number); 4901 int f = FastD2IChecked(f_number);
4899 RUNTIME_ASSERT(f >= -1 && f <= 20); 4902 RUNTIME_ASSERT(f >= -1 && f <= 20);
4903 RUNTIME_ASSERT(!Double(value).IsSpecial());
4900 char* str = DoubleToExponentialCString(value, f); 4904 char* str = DoubleToExponentialCString(value, f);
4901 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); 4905 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str);
4902 DeleteArray(str); 4906 DeleteArray(str);
4903 return *result; 4907 return *result;
4904 } 4908 }
4905 4909
4906 4910
4907 RUNTIME_FUNCTION(Runtime_NumberToPrecision) { 4911 RUNTIME_FUNCTION(Runtime_NumberToPrecision) {
4908 HandleScope scope(isolate); 4912 HandleScope scope(isolate);
4909 ASSERT(args.length() == 2); 4913 ASSERT(args.length() == 2);
4910 4914
4911 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 4915 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
4912 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); 4916 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1);
4913 int f = FastD2IChecked(f_number); 4917 int f = FastD2IChecked(f_number);
4914 RUNTIME_ASSERT(f >= 1 && f <= 21); 4918 RUNTIME_ASSERT(f >= 1 && f <= 21);
4919 RUNTIME_ASSERT(!Double(value).IsSpecial());
4915 char* str = DoubleToPrecisionCString(value, f); 4920 char* str = DoubleToPrecisionCString(value, f);
4916 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); 4921 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str);
4917 DeleteArray(str); 4922 DeleteArray(str);
4918 return *result; 4923 return *result;
4919 } 4924 }
4920 4925
4921 4926
4922 RUNTIME_FUNCTION(Runtime_IsValidSmi) { 4927 RUNTIME_FUNCTION(Runtime_IsValidSmi) {
4923 SealHandleScope shs(isolate); 4928 SealHandleScope shs(isolate);
4924 ASSERT(args.length() == 1); 4929 ASSERT(args.length() == 1);
(...skipping 10298 matching lines...) Expand 10 before | Expand all | Expand 10 after
15223 } 15228 }
15224 return NULL; 15229 return NULL;
15225 } 15230 }
15226 15231
15227 15232
15228 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15233 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15229 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15234 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15230 } 15235 }
15231 15236
15232 } } // namespace v8::internal 15237 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698