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

Side by Side Diff: src/runtime.cc

Issue 501323002: Replace our homegrown ARRAY_SIZE() with Chrome's arraysize(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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
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 "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } else if (key->ToArrayIndex(&element_index)) { 283 } else if (key->ToArrayIndex(&element_index)) {
284 // Array index (uint32). 284 // Array index (uint32).
285 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate); 285 if (value->IsUninitialized()) value = handle(Smi::FromInt(0), isolate);
286 maybe_result = 286 maybe_result =
287 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY); 287 JSObject::SetOwnElement(boilerplate, element_index, value, SLOPPY);
288 } else { 288 } else {
289 // Non-uint32 number. 289 // Non-uint32 number.
290 DCHECK(key->IsNumber()); 290 DCHECK(key->IsNumber());
291 double num = key->Number(); 291 double num = key->Number();
292 char arr[100]; 292 char arr[100];
293 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 293 Vector<char> buffer(arr, arraysize(arr));
294 const char* str = DoubleToCString(num, buffer); 294 const char* str = DoubleToCString(num, buffer);
295 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str); 295 Handle<String> name = isolate->factory()->NewStringFromAsciiChecked(str);
296 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name, 296 maybe_result = JSObject::SetOwnPropertyIgnoreAttributes(boilerplate, name,
297 value, NONE); 297 value, NONE);
298 } 298 }
299 // If setting the property on the boilerplate throws an 299 // If setting the property on the boilerplate throws an
300 // exception, the exception is converted to an empty handle in 300 // exception, the exception is converted to an empty handle in
301 // the handle based operations. In that case, we need to 301 // the handle based operations. In that case, we need to
302 // convert back to an exception. 302 // convert back to an exception.
303 RETURN_ON_EXCEPTION(isolate, maybe_result, Object); 303 RETURN_ON_EXCEPTION(isolate, maybe_result, Object);
(...skipping 14022 matching lines...) Expand 10 before | Expand all | Expand 10 after
14326 RUNTIME_FUNCTION(Runtime_StringNormalize) { 14326 RUNTIME_FUNCTION(Runtime_StringNormalize) {
14327 HandleScope scope(isolate); 14327 HandleScope scope(isolate);
14328 static const UNormalizationMode normalizationForms[] = 14328 static const UNormalizationMode normalizationForms[] =
14329 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; 14329 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD };
14330 14330
14331 DCHECK(args.length() == 2); 14331 DCHECK(args.length() == 2);
14332 14332
14333 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); 14333 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0);
14334 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); 14334 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]);
14335 RUNTIME_ASSERT(form_id >= 0 && 14335 RUNTIME_ASSERT(form_id >= 0 &&
14336 static_cast<size_t>(form_id) < ARRAY_SIZE(normalizationForms)); 14336 static_cast<size_t>(form_id) < arraysize(normalizationForms));
14337 14337
14338 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); 14338 v8::String::Value string_value(v8::Utils::ToLocal(stringValue));
14339 const UChar* u_value = reinterpret_cast<const UChar*>(*string_value); 14339 const UChar* u_value = reinterpret_cast<const UChar*>(*string_value);
14340 14340
14341 // TODO(mnita): check Normalizer2 (not available in ICU 46) 14341 // TODO(mnita): check Normalizer2 (not available in ICU 46)
14342 UErrorCode status = U_ZERO_ERROR; 14342 UErrorCode status = U_ZERO_ERROR;
14343 icu::UnicodeString result; 14343 icu::UnicodeString result;
14344 icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0, 14344 icu::Normalizer::normalize(u_value, normalizationForms[form_id], 0,
14345 result, status); 14345 result, status);
14346 if (U_FAILURE(status)) { 14346 if (U_FAILURE(status)) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
14712 Handle<Object> value; 14712 Handle<Object> value;
14713 { 14713 {
14714 Handle<JSFunction> factory(JSFunction::cast( 14714 Handle<JSFunction> factory(JSFunction::cast(
14715 cache_handle->get(JSFunctionResultCache::kFactoryIndex))); 14715 cache_handle->get(JSFunctionResultCache::kFactoryIndex)));
14716 // TODO(antonm): consider passing a receiver when constructing a cache. 14716 // TODO(antonm): consider passing a receiver when constructing a cache.
14717 Handle<JSObject> receiver(isolate->global_proxy()); 14717 Handle<JSObject> receiver(isolate->global_proxy());
14718 // This handle is nor shared, nor used later, so it's safe. 14718 // This handle is nor shared, nor used later, so it's safe.
14719 Handle<Object> argv[] = { key_handle }; 14719 Handle<Object> argv[] = { key_handle };
14720 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 14720 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
14721 isolate, value, 14721 isolate, value,
14722 Execution::Call(isolate, factory, receiver, ARRAY_SIZE(argv), argv)); 14722 Execution::Call(isolate, factory, receiver, arraysize(argv), argv));
14723 } 14723 }
14724 14724
14725 #ifdef VERIFY_HEAP 14725 #ifdef VERIFY_HEAP
14726 if (FLAG_verify_heap) { 14726 if (FLAG_verify_heap) {
14727 cache_handle->JSFunctionResultCacheVerify(); 14727 cache_handle->JSFunctionResultCacheVerify();
14728 } 14728 }
14729 #endif 14729 #endif
14730 14730
14731 // Function invocation may have cleared the cache. Reread all the data. 14731 // Function invocation may have cleared the cache. Reread all the data.
14732 int finger_index = cache_handle->finger_index(); 14732 int finger_index = cache_handle->finger_index();
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
15636 if (entry != kNotFound) { 15636 if (entry != kNotFound) {
15637 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); 15637 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry);
15638 int function_index = Smi::cast(smi_index)->value(); 15638 int function_index = Smi::cast(smi_index)->value();
15639 return &(kIntrinsicFunctions[function_index]); 15639 return &(kIntrinsicFunctions[function_index]);
15640 } 15640 }
15641 return NULL; 15641 return NULL;
15642 } 15642 }
15643 15643
15644 15644
15645 const Runtime::Function* Runtime::FunctionForEntry(Address entry) { 15645 const Runtime::Function* Runtime::FunctionForEntry(Address entry) {
15646 for (size_t i = 0; i < ARRAY_SIZE(kIntrinsicFunctions); ++i) { 15646 for (size_t i = 0; i < arraysize(kIntrinsicFunctions); ++i) {
15647 if (entry == kIntrinsicFunctions[i].entry) { 15647 if (entry == kIntrinsicFunctions[i].entry) {
15648 return &(kIntrinsicFunctions[i]); 15648 return &(kIntrinsicFunctions[i]);
15649 } 15649 }
15650 } 15650 }
15651 return NULL; 15651 return NULL;
15652 } 15652 }
15653 15653
15654 15654
15655 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15655 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15656 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15656 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15657 } 15657 }
15658 15658
15659 } } // namespace v8::internal 15659 } } // namespace v8::internal
OLDNEW
« src/base/macros.h ('K') | « src/parser.cc ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698