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

Side by Side Diff: src/runtime.cc

Issue 12210083: Renamed "symbols" to "internalized strings" throughout the code base, (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Yang's comments Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | src/scopeinfo.cc » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 281 }
282 282
283 283
284 static Handle<Map> ComputeObjectLiteralMap( 284 static Handle<Map> ComputeObjectLiteralMap(
285 Handle<Context> context, 285 Handle<Context> context,
286 Handle<FixedArray> constant_properties, 286 Handle<FixedArray> constant_properties,
287 bool* is_result_from_cache) { 287 bool* is_result_from_cache) {
288 Isolate* isolate = context->GetIsolate(); 288 Isolate* isolate = context->GetIsolate();
289 int properties_length = constant_properties->length(); 289 int properties_length = constant_properties->length();
290 int number_of_properties = properties_length / 2; 290 int number_of_properties = properties_length / 2;
291 // Check that there are only symbols and array indices among keys. 291 // Check that there are only internal strings and array indices among keys.
292 int number_of_symbol_keys = 0; 292 int number_of_string_keys = 0;
293 for (int p = 0; p != properties_length; p += 2) { 293 for (int p = 0; p != properties_length; p += 2) {
294 Object* key = constant_properties->get(p); 294 Object* key = constant_properties->get(p);
295 uint32_t element_index = 0; 295 uint32_t element_index = 0;
296 if (key->IsSymbol()) { 296 if (key->IsInternalizedString()) {
297 number_of_symbol_keys++; 297 number_of_string_keys++;
298 } else if (key->ToArrayIndex(&element_index)) { 298 } else if (key->ToArrayIndex(&element_index)) {
299 // An index key does not require space in the property backing store. 299 // An index key does not require space in the property backing store.
300 number_of_properties--; 300 number_of_properties--;
301 } else { 301 } else {
302 // Bail out as a non-symbol non-index key makes caching impossible. 302 // Bail out as a non-internalized-string non-index key makes caching
303 // impossible.
303 // ASSERT to make sure that the if condition after the loop is false. 304 // ASSERT to make sure that the if condition after the loop is false.
304 ASSERT(number_of_symbol_keys != number_of_properties); 305 ASSERT(number_of_string_keys != number_of_properties);
305 break; 306 break;
306 } 307 }
307 } 308 }
308 // If we only have symbols and array indices among keys then we can 309 // If we only have internalized strings and array indices among keys then we
309 // use the map cache in the native context. 310 // can use the map cache in the native context.
310 const int kMaxKeys = 10; 311 const int kMaxKeys = 10;
311 if ((number_of_symbol_keys == number_of_properties) && 312 if ((number_of_string_keys == number_of_properties) &&
312 (number_of_symbol_keys < kMaxKeys)) { 313 (number_of_string_keys < kMaxKeys)) {
313 // Create the fixed array with the key. 314 // Create the fixed array with the key.
314 Handle<FixedArray> keys = 315 Handle<FixedArray> keys =
315 isolate->factory()->NewFixedArray(number_of_symbol_keys); 316 isolate->factory()->NewFixedArray(number_of_string_keys);
316 if (number_of_symbol_keys > 0) { 317 if (number_of_string_keys > 0) {
317 int index = 0; 318 int index = 0;
318 for (int p = 0; p < properties_length; p += 2) { 319 for (int p = 0; p < properties_length; p += 2) {
319 Object* key = constant_properties->get(p); 320 Object* key = constant_properties->get(p);
320 if (key->IsSymbol()) { 321 if (key->IsInternalizedString()) {
321 keys->set(index++, key); 322 keys->set(index++, key);
322 } 323 }
323 } 324 }
324 ASSERT(index == number_of_symbol_keys); 325 ASSERT(index == number_of_string_keys);
325 } 326 }
326 *is_result_from_cache = true; 327 *is_result_from_cache = true;
327 return isolate->factory()->ObjectLiteralMapFromCache(context, keys); 328 return isolate->factory()->ObjectLiteralMapFromCache(context, keys);
328 } 329 }
329 *is_result_from_cache = false; 330 *is_result_from_cache = false;
330 return isolate->factory()->CopyMap( 331 return isolate->factory()->CopyMap(
331 Handle<Map>(context->object_function()->initial_map()), 332 Handle<Map>(context->object_function()->initial_map()),
332 number_of_properties); 333 number_of_properties);
333 } 334 }
334 335
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 Handle<Object> value(constant_properties->get(index+1), isolate); 388 Handle<Object> value(constant_properties->get(index+1), isolate);
388 if (value->IsFixedArray()) { 389 if (value->IsFixedArray()) {
389 // The value contains the constant_properties of a 390 // The value contains the constant_properties of a
390 // simple object or array literal. 391 // simple object or array literal.
391 Handle<FixedArray> array = Handle<FixedArray>::cast(value); 392 Handle<FixedArray> array = Handle<FixedArray>::cast(value);
392 value = CreateLiteralBoilerplate(isolate, literals, array); 393 value = CreateLiteralBoilerplate(isolate, literals, array);
393 if (value.is_null()) return value; 394 if (value.is_null()) return value;
394 } 395 }
395 Handle<Object> result; 396 Handle<Object> result;
396 uint32_t element_index = 0; 397 uint32_t element_index = 0;
397 if (key->IsSymbol()) { 398 if (key->IsInternalizedString()) {
398 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { 399 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
399 // Array index as string (uint32). 400 // Array index as string (uint32).
400 result = JSObject::SetOwnElement( 401 result = JSObject::SetOwnElement(
401 boilerplate, element_index, value, kNonStrictMode); 402 boilerplate, element_index, value, kNonStrictMode);
402 } else { 403 } else {
403 Handle<String> name(String::cast(*key)); 404 Handle<String> name(String::cast(*key));
404 ASSERT(!name->AsArrayIndex(&element_index)); 405 ASSERT(!name->AsArrayIndex(&element_index));
405 result = JSObject::SetLocalPropertyIgnoreAttributes( 406 result = JSObject::SetLocalPropertyIgnoreAttributes(
406 boilerplate, name, value, NONE); 407 boilerplate, name, value, NONE);
407 } 408 }
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { 946 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) {
946 NoHandleAllocation ha; 947 NoHandleAllocation ha;
947 ASSERT(args.length() == 1); 948 ASSERT(args.length() == 1);
948 CONVERT_ARG_CHECKED(JSReceiver, input_obj, 0); 949 CONVERT_ARG_CHECKED(JSReceiver, input_obj, 0);
949 Object* obj = input_obj; 950 Object* obj = input_obj;
950 // We don't expect access checks to be needed on JSProxy objects. 951 // We don't expect access checks to be needed on JSProxy objects.
951 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); 952 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject());
952 do { 953 do {
953 if (obj->IsAccessCheckNeeded() && 954 if (obj->IsAccessCheckNeeded() &&
954 !isolate->MayNamedAccess(JSObject::cast(obj), 955 !isolate->MayNamedAccess(JSObject::cast(obj),
955 isolate->heap()->Proto_symbol(), 956 isolate->heap()->proto_string(),
956 v8::ACCESS_GET)) { 957 v8::ACCESS_GET)) {
957 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET); 958 isolate->ReportFailedAccessCheck(JSObject::cast(obj), v8::ACCESS_GET);
958 return isolate->heap()->undefined_value(); 959 return isolate->heap()->undefined_value();
959 } 960 }
960 obj = obj->GetPrototype(); 961 obj = obj->GetPrototype();
961 } while (obj->IsJSObject() && 962 } while (obj->IsJSObject() &&
962 JSObject::cast(obj)->map()->is_hidden_prototype()); 963 JSObject::cast(obj)->map()->is_hidden_prototype());
963 return obj; 964 return obj;
964 } 965 }
965 966
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 } 1772 }
1772 1773
1773 1774
1774 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { 1775 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) {
1775 AssertNoAllocation no_alloc; 1776 AssertNoAllocation no_alloc;
1776 ASSERT(args.length() == 5); 1777 ASSERT(args.length() == 5);
1777 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0); 1778 CONVERT_ARG_CHECKED(JSRegExp, regexp, 0);
1778 CONVERT_ARG_CHECKED(String, source, 1); 1779 CONVERT_ARG_CHECKED(String, source, 1);
1779 // If source is the empty string we set it to "(?:)" instead as 1780 // If source is the empty string we set it to "(?:)" instead as
1780 // suggested by ECMA-262, 5th, section 15.10.4.1. 1781 // suggested by ECMA-262, 5th, section 15.10.4.1.
1781 if (source->length() == 0) source = isolate->heap()->query_colon_symbol(); 1782 if (source->length() == 0) source = isolate->heap()->query_colon_string();
1782 1783
1783 Object* global = args[2]; 1784 Object* global = args[2];
1784 if (!global->IsTrue()) global = isolate->heap()->false_value(); 1785 if (!global->IsTrue()) global = isolate->heap()->false_value();
1785 1786
1786 Object* ignoreCase = args[3]; 1787 Object* ignoreCase = args[3];
1787 if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value(); 1788 if (!ignoreCase->IsTrue()) ignoreCase = isolate->heap()->false_value();
1788 1789
1789 Object* multiline = args[4]; 1790 Object* multiline = args[4];
1790 if (!multiline->IsTrue()) multiline = isolate->heap()->false_value(); 1791 if (!multiline->IsTrue()) multiline = isolate->heap()->false_value();
1791 1792
(...skipping 16 matching lines...) Expand all
1808 return regexp; 1809 return regexp;
1809 } 1810 }
1810 1811
1811 // Map has changed, so use generic, but slower, method. 1812 // Map has changed, so use generic, but slower, method.
1812 PropertyAttributes final = 1813 PropertyAttributes final =
1813 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); 1814 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE);
1814 PropertyAttributes writable = 1815 PropertyAttributes writable =
1815 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 1816 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
1816 Heap* heap = isolate->heap(); 1817 Heap* heap = isolate->heap();
1817 MaybeObject* result; 1818 MaybeObject* result;
1818 result = regexp->SetLocalPropertyIgnoreAttributes(heap->source_symbol(), 1819 result = regexp->SetLocalPropertyIgnoreAttributes(heap->source_string(),
1819 source, 1820 source,
1820 final); 1821 final);
1821 // TODO(jkummerow): Turn these back into ASSERTs when we can be certain 1822 // TODO(jkummerow): Turn these back into ASSERTs when we can be certain
1822 // that it never fires in Release mode in the wild. 1823 // that it never fires in Release mode in the wild.
1823 CHECK(!result->IsFailure()); 1824 CHECK(!result->IsFailure());
1824 result = regexp->SetLocalPropertyIgnoreAttributes(heap->global_symbol(), 1825 result = regexp->SetLocalPropertyIgnoreAttributes(heap->global_string(),
1825 global, 1826 global,
1826 final); 1827 final);
1827 CHECK(!result->IsFailure()); 1828 CHECK(!result->IsFailure());
1828 result = 1829 result =
1829 regexp->SetLocalPropertyIgnoreAttributes(heap->ignore_case_symbol(), 1830 regexp->SetLocalPropertyIgnoreAttributes(heap->ignore_case_string(),
1830 ignoreCase, 1831 ignoreCase,
1831 final); 1832 final);
1832 CHECK(!result->IsFailure()); 1833 CHECK(!result->IsFailure());
1833 result = regexp->SetLocalPropertyIgnoreAttributes(heap->multiline_symbol(), 1834 result = regexp->SetLocalPropertyIgnoreAttributes(heap->multiline_string(),
1834 multiline, 1835 multiline,
1835 final); 1836 final);
1836 CHECK(!result->IsFailure()); 1837 CHECK(!result->IsFailure());
1837 result = 1838 result =
1838 regexp->SetLocalPropertyIgnoreAttributes(heap->last_index_symbol(), 1839 regexp->SetLocalPropertyIgnoreAttributes(heap->last_index_string(),
1839 Smi::FromInt(0), 1840 Smi::FromInt(0),
1840 writable); 1841 writable);
1841 CHECK(!result->IsFailure()); 1842 CHECK(!result->IsFailure());
1842 USE(result); 1843 USE(result);
1843 return regexp; 1844 return regexp;
1844 } 1845 }
1845 1846
1846 1847
1847 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinishArrayPrototypeSetup) { 1848 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinishArrayPrototypeSetup) {
1848 HandleScope scope(isolate); 1849 HandleScope scope(isolate);
1849 ASSERT(args.length() == 1); 1850 ASSERT(args.length() == 1);
1850 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); 1851 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0);
1851 // This is necessary to enable fast checks for absence of elements 1852 // This is necessary to enable fast checks for absence of elements
1852 // on Array.prototype and below. 1853 // on Array.prototype and below.
1853 prototype->set_elements(isolate->heap()->empty_fixed_array()); 1854 prototype->set_elements(isolate->heap()->empty_fixed_array());
1854 return Smi::FromInt(0); 1855 return Smi::FromInt(0);
1855 } 1856 }
1856 1857
1857 1858
1858 static Handle<JSFunction> InstallBuiltin(Isolate* isolate, 1859 static Handle<JSFunction> InstallBuiltin(Isolate* isolate,
1859 Handle<JSObject> holder, 1860 Handle<JSObject> holder,
1860 const char* name, 1861 const char* name,
1861 Builtins::Name builtin_name) { 1862 Builtins::Name builtin_name) {
1862 Handle<String> key = isolate->factory()->LookupUtf8Symbol(name); 1863 Handle<String> key = isolate->factory()->InternalizeUtf8String(name);
1863 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); 1864 Handle<Code> code(isolate->builtins()->builtin(builtin_name));
1864 Handle<JSFunction> optimized = 1865 Handle<JSFunction> optimized =
1865 isolate->factory()->NewFunction(key, 1866 isolate->factory()->NewFunction(key,
1866 JS_OBJECT_TYPE, 1867 JS_OBJECT_TYPE,
1867 JSObject::kHeaderSize, 1868 JSObject::kHeaderSize,
1868 code, 1869 code,
1869 false); 1870 false);
1870 optimized->shared()->DontAdaptArguments(); 1871 optimized->shared()->DontAdaptArguments();
1871 JSReceiver::SetProperty(holder, key, optimized, NONE, kStrictMode); 1872 JSReceiver::SetProperty(holder, key, optimized, NONE, kStrictMode);
1872 return optimized; 1873 return optimized;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 } 2077 }
2077 return args[0]; // return TOS 2078 return args[0]; // return TOS
2078 } 2079 }
2079 2080
2080 2081
2081 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { 2082 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) {
2082 NoHandleAllocation ha; 2083 NoHandleAllocation ha;
2083 RUNTIME_ASSERT(args.length() == 1); 2084 RUNTIME_ASSERT(args.length() == 1);
2084 CONVERT_ARG_CHECKED(JSFunction, function, 0); 2085 CONVERT_ARG_CHECKED(JSFunction, function, 0);
2085 2086
2086 String* name = isolate->heap()->prototype_symbol(); 2087 String* name = isolate->heap()->prototype_string();
2087 2088
2088 if (function->HasFastProperties()) { 2089 if (function->HasFastProperties()) {
2089 // Construct a new field descriptor with updated attributes. 2090 // Construct a new field descriptor with updated attributes.
2090 DescriptorArray* instance_desc = function->map()->instance_descriptors(); 2091 DescriptorArray* instance_desc = function->map()->instance_descriptors();
2091 2092
2092 int index = instance_desc->SearchWithCache(name, function->map()); 2093 int index = instance_desc->SearchWithCache(name, function->map());
2093 ASSERT(index != DescriptorArray::kNotFound); 2094 ASSERT(index != DescriptorArray::kNotFound);
2094 PropertyDetails details = instance_desc->GetDetails(index); 2095 PropertyDetails details = instance_desc->GetDetails(index);
2095 2096
2096 CallbacksDescriptor new_desc(name, 2097 CallbacksDescriptor new_desc(name,
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
3795 // Character array used for conversion. 3796 // Character array used for conversion.
3796 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz"; 3797 static const char kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz";
3797 return isolate->heap()-> 3798 return isolate->heap()->
3798 LookupSingleCharacterStringFromCode(kCharTable[value]); 3799 LookupSingleCharacterStringFromCode(kCharTable[value]);
3799 } 3800 }
3800 } 3801 }
3801 3802
3802 // Slow case. 3803 // Slow case.
3803 CONVERT_DOUBLE_ARG_CHECKED(value, 0); 3804 CONVERT_DOUBLE_ARG_CHECKED(value, 0);
3804 if (isnan(value)) { 3805 if (isnan(value)) {
3805 return *isolate->factory()->nan_symbol(); 3806 return *isolate->factory()->nan_string();
3806 } 3807 }
3807 if (isinf(value)) { 3808 if (isinf(value)) {
3808 if (value < 0) { 3809 if (value < 0) {
3809 return *isolate->factory()->minus_infinity_symbol(); 3810 return *isolate->factory()->minus_infinity_string();
3810 } 3811 }
3811 return *isolate->factory()->infinity_symbol(); 3812 return *isolate->factory()->infinity_string();
3812 } 3813 }
3813 char* str = DoubleToRadixCString(value, radix); 3814 char* str = DoubleToRadixCString(value, radix);
3814 MaybeObject* result = 3815 MaybeObject* result =
3815 isolate->heap()->AllocateStringFromOneByte(CStrVector(str)); 3816 isolate->heap()->AllocateStringFromOneByte(CStrVector(str));
3816 DeleteArray(str); 3817 DeleteArray(str);
3817 return result; 3818 return result;
3818 } 3819 }
3819 3820
3820 3821
3821 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { 3822 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) {
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after
4782 } 4783 }
4783 4784
4784 // Filter out name of hidden propeties object. 4785 // Filter out name of hidden propeties object.
4785 if (proto_with_hidden_properties > 0) { 4786 if (proto_with_hidden_properties > 0) {
4786 Handle<FixedArray> old_names = names; 4787 Handle<FixedArray> old_names = names;
4787 names = isolate->factory()->NewFixedArray( 4788 names = isolate->factory()->NewFixedArray(
4788 names->length() - proto_with_hidden_properties); 4789 names->length() - proto_with_hidden_properties);
4789 int dest_pos = 0; 4790 int dest_pos = 0;
4790 for (int i = 0; i < total_property_count; i++) { 4791 for (int i = 0; i < total_property_count; i++) {
4791 Object* name = old_names->get(i); 4792 Object* name = old_names->get(i);
4792 if (name == isolate->heap()->hidden_symbol()) { 4793 if (name == isolate->heap()->hidden_string()) {
4793 continue; 4794 continue;
4794 } 4795 }
4795 names->set(dest_pos++, name); 4796 names->set(dest_pos++, name);
4796 } 4797 }
4797 } 4798 }
4798 4799
4799 return *isolate->factory()->NewJSArrayWithElements(names); 4800 return *isolate->factory()->NewJSArrayWithElements(names);
4800 } 4801 }
4801 4802
4802 4803
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
4943 // Try to convert the string key into an array index. 4944 // Try to convert the string key into an array index.
4944 if (key->AsArrayIndex(&index)) { 4945 if (key->AsArrayIndex(&index)) {
4945 if (index < n) { 4946 if (index < n) {
4946 return frame->GetParameter(index); 4947 return frame->GetParameter(index);
4947 } else { 4948 } else {
4948 return isolate->initial_object_prototype()->GetElement(index); 4949 return isolate->initial_object_prototype()->GetElement(index);
4949 } 4950 }
4950 } 4951 }
4951 4952
4952 // Handle special arguments properties. 4953 // Handle special arguments properties.
4953 if (key->Equals(isolate->heap()->length_symbol())) return Smi::FromInt(n); 4954 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n);
4954 if (key->Equals(isolate->heap()->callee_symbol())) { 4955 if (key->Equals(isolate->heap()->callee_string())) {
4955 Object* function = frame->function(); 4956 Object* function = frame->function();
4956 if (function->IsJSFunction() && 4957 if (function->IsJSFunction() &&
4957 !JSFunction::cast(function)->shared()->is_classic_mode()) { 4958 !JSFunction::cast(function)->shared()->is_classic_mode()) {
4958 return isolate->Throw(*isolate->factory()->NewTypeError( 4959 return isolate->Throw(*isolate->factory()->NewTypeError(
4959 "strict_arguments_callee", HandleVector<Object>(NULL, 0))); 4960 "strict_arguments_callee", HandleVector<Object>(NULL, 0)));
4960 } 4961 }
4961 return function; 4962 return function;
4962 } 4963 }
4963 4964
4964 // Lookup in the initial Object.prototype object. 4965 // Lookup in the initial Object.prototype object.
(...skipping 17 matching lines...) Expand all
4982 return args[0]->ToBoolean(); 4983 return args[0]->ToBoolean();
4983 } 4984 }
4984 4985
4985 4986
4986 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). 4987 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47).
4987 // Possible optimizations: put the type string into the oddballs. 4988 // Possible optimizations: put the type string into the oddballs.
4988 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { 4989 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) {
4989 NoHandleAllocation ha; 4990 NoHandleAllocation ha;
4990 4991
4991 Object* obj = args[0]; 4992 Object* obj = args[0];
4992 if (obj->IsNumber()) return isolate->heap()->number_symbol(); 4993 if (obj->IsNumber()) return isolate->heap()->number_string();
4993 HeapObject* heap_obj = HeapObject::cast(obj); 4994 HeapObject* heap_obj = HeapObject::cast(obj);
4994 4995
4995 // typeof an undetectable object is 'undefined' 4996 // typeof an undetectable object is 'undefined'
4996 if (heap_obj->map()->is_undetectable()) { 4997 if (heap_obj->map()->is_undetectable()) {
4997 return isolate->heap()->undefined_symbol(); 4998 return isolate->heap()->undefined_string();
4998 } 4999 }
4999 5000
5000 InstanceType instance_type = heap_obj->map()->instance_type(); 5001 InstanceType instance_type = heap_obj->map()->instance_type();
5001 if (instance_type < FIRST_NONSTRING_TYPE) { 5002 if (instance_type < FIRST_NONSTRING_TYPE) {
5002 return isolate->heap()->string_symbol(); 5003 return isolate->heap()->string_string();
5003 } 5004 }
5004 5005
5005 switch (instance_type) { 5006 switch (instance_type) {
5006 case ODDBALL_TYPE: 5007 case ODDBALL_TYPE:
5007 if (heap_obj->IsTrue() || heap_obj->IsFalse()) { 5008 if (heap_obj->IsTrue() || heap_obj->IsFalse()) {
5008 return isolate->heap()->boolean_symbol(); 5009 return isolate->heap()->boolean_string();
5009 } 5010 }
5010 if (heap_obj->IsNull()) { 5011 if (heap_obj->IsNull()) {
5011 return FLAG_harmony_typeof 5012 return FLAG_harmony_typeof
5012 ? isolate->heap()->null_symbol() 5013 ? isolate->heap()->null_string()
5013 : isolate->heap()->object_symbol(); 5014 : isolate->heap()->object_string();
5014 } 5015 }
5015 ASSERT(heap_obj->IsUndefined()); 5016 ASSERT(heap_obj->IsUndefined());
5016 return isolate->heap()->undefined_symbol(); 5017 return isolate->heap()->undefined_string();
5017 case JS_FUNCTION_TYPE: 5018 case JS_FUNCTION_TYPE:
5018 case JS_FUNCTION_PROXY_TYPE: 5019 case JS_FUNCTION_PROXY_TYPE:
5019 return isolate->heap()->function_symbol(); 5020 return isolate->heap()->function_string();
5020 default: 5021 default:
5021 // For any kind of object not handled above, the spec rule for 5022 // For any kind of object not handled above, the spec rule for
5022 // host objects gives that it is okay to return "object" 5023 // host objects gives that it is okay to return "object"
5023 return isolate->heap()->object_symbol(); 5024 return isolate->heap()->object_string();
5024 } 5025 }
5025 } 5026 }
5026 5027
5027 5028
5028 static bool AreDigits(const uint8_t*s, int from, int to) { 5029 static bool AreDigits(const uint8_t*s, int from, int to) {
5029 for (int i = from; i < to; i++) { 5030 for (int i = from; i < to; i++) {
5030 if (s[i] < '0' || s[i] > '9') return false; 5031 if (s[i] < '0' || s[i] > '9') return false;
5031 } 5032 }
5032 5033
5033 return true; 5034 return true;
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
6515 CONVERT_ARG_CHECKED(String, special, 2); 6516 CONVERT_ARG_CHECKED(String, special, 2);
6516 6517
6517 // This assumption is used by the slice encoding in one or two smis. 6518 // This assumption is used by the slice encoding in one or two smis.
6518 ASSERT(Smi::kMaxValue >= String::kMaxLength); 6519 ASSERT(Smi::kMaxValue >= String::kMaxLength);
6519 6520
6520 MaybeObject* maybe_result = array->EnsureCanContainHeapObjectElements(); 6521 MaybeObject* maybe_result = array->EnsureCanContainHeapObjectElements();
6521 if (maybe_result->IsFailure()) return maybe_result; 6522 if (maybe_result->IsFailure()) return maybe_result;
6522 6523
6523 int special_length = special->length(); 6524 int special_length = special->length();
6524 if (!array->HasFastObjectElements()) { 6525 if (!array->HasFastObjectElements()) {
6525 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6526 return isolate->Throw(isolate->heap()->illegal_argument_string());
6526 } 6527 }
6527 FixedArray* fixed_array = FixedArray::cast(array->elements()); 6528 FixedArray* fixed_array = FixedArray::cast(array->elements());
6528 if (fixed_array->length() < array_length) { 6529 if (fixed_array->length() < array_length) {
6529 array_length = fixed_array->length(); 6530 array_length = fixed_array->length();
6530 } 6531 }
6531 6532
6532 if (array_length == 0) { 6533 if (array_length == 0) {
6533 return isolate->heap()->empty_string(); 6534 return isolate->heap()->empty_string();
6534 } else if (array_length == 1) { 6535 } else if (array_length == 1) {
6535 Object* first = fixed_array->get(0); 6536 Object* first = fixed_array->get(0);
(...skipping 13 matching lines...) Expand all
6549 if (smi_value > 0) { 6550 if (smi_value > 0) {
6550 // Position and length encoded in one smi. 6551 // Position and length encoded in one smi.
6551 pos = StringBuilderSubstringPosition::decode(smi_value); 6552 pos = StringBuilderSubstringPosition::decode(smi_value);
6552 len = StringBuilderSubstringLength::decode(smi_value); 6553 len = StringBuilderSubstringLength::decode(smi_value);
6553 } else { 6554 } else {
6554 // Position and length encoded in two smis. 6555 // Position and length encoded in two smis.
6555 len = -smi_value; 6556 len = -smi_value;
6556 // Get the position and check that it is a positive smi. 6557 // Get the position and check that it is a positive smi.
6557 i++; 6558 i++;
6558 if (i >= array_length) { 6559 if (i >= array_length) {
6559 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6560 return isolate->Throw(isolate->heap()->illegal_argument_string());
6560 } 6561 }
6561 Object* next_smi = fixed_array->get(i); 6562 Object* next_smi = fixed_array->get(i);
6562 if (!next_smi->IsSmi()) { 6563 if (!next_smi->IsSmi()) {
6563 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6564 return isolate->Throw(isolate->heap()->illegal_argument_string());
6564 } 6565 }
6565 pos = Smi::cast(next_smi)->value(); 6566 pos = Smi::cast(next_smi)->value();
6566 if (pos < 0) { 6567 if (pos < 0) {
6567 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6568 return isolate->Throw(isolate->heap()->illegal_argument_string());
6568 } 6569 }
6569 } 6570 }
6570 ASSERT(pos >= 0); 6571 ASSERT(pos >= 0);
6571 ASSERT(len >= 0); 6572 ASSERT(len >= 0);
6572 if (pos > special_length || len > special_length - pos) { 6573 if (pos > special_length || len > special_length - pos) {
6573 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6574 return isolate->Throw(isolate->heap()->illegal_argument_string());
6574 } 6575 }
6575 increment = len; 6576 increment = len;
6576 } else if (elt->IsString()) { 6577 } else if (elt->IsString()) {
6577 String* element = String::cast(elt); 6578 String* element = String::cast(elt);
6578 int element_length = element->length(); 6579 int element_length = element->length();
6579 increment = element_length; 6580 increment = element_length;
6580 if (one_byte && !element->IsOneByteConvertible()) { 6581 if (one_byte && !element->IsOneByteConvertible()) {
6581 one_byte = false; 6582 one_byte = false;
6582 } 6583 }
6583 } else { 6584 } else {
6584 ASSERT(!elt->IsTheHole()); 6585 ASSERT(!elt->IsTheHole());
6585 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6586 return isolate->Throw(isolate->heap()->illegal_argument_string());
6586 } 6587 }
6587 if (increment > String::kMaxLength - position) { 6588 if (increment > String::kMaxLength - position) {
6588 isolate->context()->mark_out_of_memory(); 6589 isolate->context()->mark_out_of_memory();
6589 return Failure::OutOfMemoryException(0x15); 6590 return Failure::OutOfMemoryException(0x15);
6590 } 6591 }
6591 position += increment; 6592 position += increment;
6592 } 6593 }
6593 6594
6594 int length = position; 6595 int length = position;
6595 Object* object; 6596 Object* object;
(...skipping 29 matching lines...) Expand all
6625 ASSERT(args.length() == 3); 6626 ASSERT(args.length() == 3);
6626 CONVERT_ARG_CHECKED(JSArray, array, 0); 6627 CONVERT_ARG_CHECKED(JSArray, array, 0);
6627 if (!args[1]->IsSmi()) { 6628 if (!args[1]->IsSmi()) {
6628 isolate->context()->mark_out_of_memory(); 6629 isolate->context()->mark_out_of_memory();
6629 return Failure::OutOfMemoryException(0x16); 6630 return Failure::OutOfMemoryException(0x16);
6630 } 6631 }
6631 int array_length = args.smi_at(1); 6632 int array_length = args.smi_at(1);
6632 CONVERT_ARG_CHECKED(String, separator, 2); 6633 CONVERT_ARG_CHECKED(String, separator, 2);
6633 6634
6634 if (!array->HasFastObjectElements()) { 6635 if (!array->HasFastObjectElements()) {
6635 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6636 return isolate->Throw(isolate->heap()->illegal_argument_string());
6636 } 6637 }
6637 FixedArray* fixed_array = FixedArray::cast(array->elements()); 6638 FixedArray* fixed_array = FixedArray::cast(array->elements());
6638 if (fixed_array->length() < array_length) { 6639 if (fixed_array->length() < array_length) {
6639 array_length = fixed_array->length(); 6640 array_length = fixed_array->length();
6640 } 6641 }
6641 6642
6642 if (array_length == 0) { 6643 if (array_length == 0) {
6643 return isolate->heap()->empty_string(); 6644 return isolate->heap()->empty_string();
6644 } else if (array_length == 1) { 6645 } else if (array_length == 1) {
6645 Object* first = fixed_array->get(0); 6646 Object* first = fixed_array->get(0);
6646 if (first->IsString()) return first; 6647 if (first->IsString()) return first;
6647 } 6648 }
6648 6649
6649 int separator_length = separator->length(); 6650 int separator_length = separator->length();
6650 int max_nof_separators = 6651 int max_nof_separators =
6651 (String::kMaxLength + separator_length - 1) / separator_length; 6652 (String::kMaxLength + separator_length - 1) / separator_length;
6652 if (max_nof_separators < (array_length - 1)) { 6653 if (max_nof_separators < (array_length - 1)) {
6653 isolate->context()->mark_out_of_memory(); 6654 isolate->context()->mark_out_of_memory();
6654 return Failure::OutOfMemoryException(0x17); 6655 return Failure::OutOfMemoryException(0x17);
6655 } 6656 }
6656 int length = (array_length - 1) * separator_length; 6657 int length = (array_length - 1) * separator_length;
6657 for (int i = 0; i < array_length; i++) { 6658 for (int i = 0; i < array_length; i++) {
6658 Object* element_obj = fixed_array->get(i); 6659 Object* element_obj = fixed_array->get(i);
6659 if (!element_obj->IsString()) { 6660 if (!element_obj->IsString()) {
6660 // TODO(1161): handle this case. 6661 // TODO(1161): handle this case.
6661 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 6662 return isolate->Throw(isolate->heap()->illegal_argument_string());
6662 } 6663 }
6663 String* element = String::cast(element_obj); 6664 String* element = String::cast(element_obj);
6664 int increment = element->length(); 6665 int increment = element->length();
6665 if (increment > String::kMaxLength - length) { 6666 if (increment > String::kMaxLength - length) {
6666 isolate->context()->mark_out_of_memory(); 6667 isolate->context()->mark_out_of_memory();
6667 return Failure::OutOfMemoryException(0x18); 6668 return Failure::OutOfMemoryException(0x18);
6668 } 6669 }
6669 length += increment; 6670 length += increment;
6670 } 6671 }
6671 6672
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
7656 } 7657 }
7657 // Copy arguments, skipping the first which is "this_arg". 7658 // Copy arguments, skipping the first which is "this_arg".
7658 for (int j = 0; j < argc; j++, i++) { 7659 for (int j = 0; j < argc; j++, i++) {
7659 new_bindings->set(i, *arguments[j + 1]); 7660 new_bindings->set(i, *arguments[j + 1]);
7660 } 7661 }
7661 new_bindings->set_map_no_write_barrier( 7662 new_bindings->set_map_no_write_barrier(
7662 isolate->heap()->fixed_cow_array_map()); 7663 isolate->heap()->fixed_cow_array_map());
7663 bound_function->set_function_bindings(*new_bindings); 7664 bound_function->set_function_bindings(*new_bindings);
7664 7665
7665 // Update length. 7666 // Update length.
7666 Handle<String> length_symbol = isolate->factory()->length_symbol(); 7667 Handle<String> length_string = isolate->factory()->length_string();
7667 Handle<Object> new_length(args.at<Object>(3)); 7668 Handle<Object> new_length(args.at<Object>(3));
7668 PropertyAttributes attr = 7669 PropertyAttributes attr =
7669 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY); 7670 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY);
7670 ForceSetProperty(bound_function, length_symbol, new_length, attr); 7671 ForceSetProperty(bound_function, length_string, new_length, attr);
7671 return *bound_function; 7672 return *bound_function;
7672 } 7673 }
7673 7674
7674 7675
7675 RUNTIME_FUNCTION(MaybeObject*, Runtime_BoundFunctionGetBindings) { 7676 RUNTIME_FUNCTION(MaybeObject*, Runtime_BoundFunctionGetBindings) {
7676 HandleScope handles(isolate); 7677 HandleScope handles(isolate);
7677 ASSERT(args.length() == 1); 7678 ASSERT(args.length() == 1);
7678 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0); 7679 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0);
7679 if (callable->IsJSFunction()) { 7680 if (callable->IsJSFunction()) {
7680 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); 7681 Handle<JSFunction> function = Handle<JSFunction>::cast(callable);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
7912 Compiler::RecompileParallel(args.at<JSFunction>(0)); 7913 Compiler::RecompileParallel(args.at<JSFunction>(0));
7913 return isolate->heap()->undefined_value(); 7914 return isolate->heap()->undefined_value();
7914 } 7915 }
7915 7916
7916 7917
7917 RUNTIME_FUNCTION(MaybeObject*, Runtime_ForceParallelRecompile) { 7918 RUNTIME_FUNCTION(MaybeObject*, Runtime_ForceParallelRecompile) {
7918 if (!V8::UseCrankshaft()) return isolate->heap()->undefined_value(); 7919 if (!V8::UseCrankshaft()) return isolate->heap()->undefined_value();
7919 HandleScope handle_scope(isolate); 7920 HandleScope handle_scope(isolate);
7920 ASSERT(FLAG_parallel_recompilation && FLAG_manual_parallel_recompilation); 7921 ASSERT(FLAG_parallel_recompilation && FLAG_manual_parallel_recompilation);
7921 if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) { 7922 if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) {
7922 return isolate->Throw(*isolate->factory()->LookupOneByteSymbol( 7923 return isolate->Throw(*isolate->factory()->InternalizeOneByteString(
7923 STATIC_ASCII_VECTOR("Recompile queue is full."))); 7924 STATIC_ASCII_VECTOR("Recompile queue is full.")));
7924 } 7925 }
7925 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 7926 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
7926 fun->ReplaceCode(isolate->builtins()->builtin(Builtins::kParallelRecompile)); 7927 fun->ReplaceCode(isolate->builtins()->builtin(Builtins::kParallelRecompile));
7927 Compiler::RecompileParallel(fun); 7928 Compiler::RecompileParallel(fun);
7928 return isolate->heap()->undefined_value(); 7929 return isolate->heap()->undefined_value();
7929 } 7930 }
7930 7931
7931 7932
7932 RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) { 7933 RUNTIME_FUNCTION(MaybeObject*, Runtime_InstallRecompiledCode) {
(...skipping 2430 matching lines...) Expand 10 before | Expand all | Expand 10 after
10363 } 10364 }
10364 10365
10365 10366
10366 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) { 10367 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) {
10367 ASSERT(args.length() >= 1); 10368 ASSERT(args.length() >= 1);
10368 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); 10369 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]);
10369 // Check that the break id is valid. 10370 // Check that the break id is valid.
10370 if (isolate->debug()->break_id() == 0 || 10371 if (isolate->debug()->break_id() == 0 ||
10371 break_id != isolate->debug()->break_id()) { 10372 break_id != isolate->debug()->break_id()) {
10372 return isolate->Throw( 10373 return isolate->Throw(
10373 isolate->heap()->illegal_execution_state_symbol()); 10374 isolate->heap()->illegal_execution_state_string());
10374 } 10375 }
10375 10376
10376 return isolate->heap()->true_value(); 10377 return isolate->heap()->true_value();
10377 } 10378 }
10378 10379
10379 10380
10380 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameCount) { 10381 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameCount) {
10381 HandleScope scope(isolate); 10382 HandleScope scope(isolate);
10382 ASSERT(args.length() == 1); 10383 ASSERT(args.length() == 1);
10383 10384
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after
11912 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrepareStep) { 11913 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrepareStep) {
11913 HandleScope scope(isolate); 11914 HandleScope scope(isolate);
11914 ASSERT(args.length() == 3); 11915 ASSERT(args.length() == 3);
11915 // Check arguments. 11916 // Check arguments.
11916 Object* check; 11917 Object* check;
11917 { MaybeObject* maybe_check = Runtime_CheckExecutionState( 11918 { MaybeObject* maybe_check = Runtime_CheckExecutionState(
11918 RUNTIME_ARGUMENTS(isolate, args)); 11919 RUNTIME_ARGUMENTS(isolate, args));
11919 if (!maybe_check->ToObject(&check)) return maybe_check; 11920 if (!maybe_check->ToObject(&check)) return maybe_check;
11920 } 11921 }
11921 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { 11922 if (!args[1]->IsNumber() || !args[2]->IsNumber()) {
11922 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 11923 return isolate->Throw(isolate->heap()->illegal_argument_string());
11923 } 11924 }
11924 11925
11925 // Get the step action and check validity. 11926 // Get the step action and check validity.
11926 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1])); 11927 StepAction step_action = static_cast<StepAction>(NumberToInt32(args[1]));
11927 if (step_action != StepIn && 11928 if (step_action != StepIn &&
11928 step_action != StepNext && 11929 step_action != StepNext &&
11929 step_action != StepOut && 11930 step_action != StepOut &&
11930 step_action != StepInMin && 11931 step_action != StepInMin &&
11931 step_action != StepMin) { 11932 step_action != StepMin) {
11932 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 11933 return isolate->Throw(isolate->heap()->illegal_argument_string());
11933 } 11934 }
11934 11935
11935 // Get the number of steps. 11936 // Get the number of steps.
11936 int step_count = NumberToInt32(args[2]); 11937 int step_count = NumberToInt32(args[2]);
11937 if (step_count < 1) { 11938 if (step_count < 1) {
11938 return isolate->Throw(isolate->heap()->illegal_argument_symbol()); 11939 return isolate->Throw(isolate->heap()->illegal_argument_string());
11939 } 11940 }
11940 11941
11941 // Clear all current stepping setup. 11942 // Clear all current stepping setup.
11942 isolate->debug()->ClearStepping(); 11943 isolate->debug()->ClearStepping();
11943 11944
11944 // Prepare step. 11945 // Prepare step.
11945 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), 11946 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action),
11946 step_count); 11947 step_count);
11947 return isolate->heap()->undefined_value(); 11948 return isolate->heap()->undefined_value();
11948 } 11949 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
12026 static Handle<Object> GetArgumentsObject(Isolate* isolate, 12027 static Handle<Object> GetArgumentsObject(Isolate* isolate,
12027 JavaScriptFrame* frame, 12028 JavaScriptFrame* frame,
12028 FrameInspector* frame_inspector, 12029 FrameInspector* frame_inspector,
12029 Handle<ScopeInfo> scope_info, 12030 Handle<ScopeInfo> scope_info,
12030 Handle<Context> function_context) { 12031 Handle<Context> function_context) {
12031 // Try to find the value of 'arguments' to pass as parameter. If it is not 12032 // Try to find the value of 'arguments' to pass as parameter. If it is not
12032 // found (that is the debugged function does not reference 'arguments' and 12033 // found (that is the debugged function does not reference 'arguments' and
12033 // does not support eval) then create an 'arguments' object. 12034 // does not support eval) then create an 'arguments' object.
12034 int index; 12035 int index;
12035 if (scope_info->StackLocalCount() > 0) { 12036 if (scope_info->StackLocalCount() > 0) {
12036 index = scope_info->StackSlotIndex(isolate->heap()->arguments_symbol()); 12037 index = scope_info->StackSlotIndex(isolate->heap()->arguments_string());
12037 if (index != -1) { 12038 if (index != -1) {
12038 return Handle<Object>(frame->GetExpression(index), isolate); 12039 return Handle<Object>(frame->GetExpression(index), isolate);
12039 } 12040 }
12040 } 12041 }
12041 12042
12042 if (scope_info->HasHeapAllocatedLocals()) { 12043 if (scope_info->HasHeapAllocatedLocals()) {
12043 VariableMode mode; 12044 VariableMode mode;
12044 InitializationFlag init_flag; 12045 InitializationFlag init_flag;
12045 index = scope_info->ContextSlotIndex( 12046 index = scope_info->ContextSlotIndex(
12046 isolate->heap()->arguments_symbol(), &mode, &init_flag); 12047 isolate->heap()->arguments_string(), &mode, &init_flag);
12047 if (index != -1) { 12048 if (index != -1) {
12048 return Handle<Object>(function_context->get(index), isolate); 12049 return Handle<Object>(function_context->get(index), isolate);
12049 } 12050 }
12050 } 12051 }
12051 12052
12052 Handle<JSFunction> function(JSFunction::cast(frame_inspector->GetFunction())); 12053 Handle<JSFunction> function(JSFunction::cast(frame_inspector->GetFunction()));
12053 int length = frame_inspector->GetParametersCount(); 12054 int length = frame_inspector->GetParametersCount();
12054 Handle<JSObject> arguments = 12055 Handle<JSObject> arguments =
12055 isolate->factory()->NewArgumentsObject(function, length); 12056 isolate->factory()->NewArgumentsObject(function, length);
12056 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length); 12057 Handle<FixedArray> array = isolate->factory()->NewFixedArray(length);
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
12891 JavaScriptFrameIterator it(isolate, id); 12892 JavaScriptFrameIterator it(isolate, id);
12892 for (; !it.done(); it.Advance()) { 12893 for (; !it.done(); it.Advance()) {
12893 if (index < count + it.frame()->GetInlineCount()) break; 12894 if (index < count + it.frame()->GetInlineCount()) break;
12894 count += it.frame()->GetInlineCount(); 12895 count += it.frame()->GetInlineCount();
12895 } 12896 }
12896 if (it.done()) return heap->undefined_value(); 12897 if (it.done()) return heap->undefined_value();
12897 12898
12898 const char* error_message = 12899 const char* error_message =
12899 LiveEdit::RestartFrame(it.frame(), isolate->runtime_zone()); 12900 LiveEdit::RestartFrame(it.frame(), isolate->runtime_zone());
12900 if (error_message) { 12901 if (error_message) {
12901 return *(isolate->factory()->LookupUtf8Symbol(error_message)); 12902 return *(isolate->factory()->InternalizeUtf8String(error_message));
12902 } 12903 }
12903 return heap->true_value(); 12904 return heap->true_value();
12904 } 12905 }
12905 12906
12906 12907
12907 // A testing entry. Returns statement position which is the closest to 12908 // A testing entry. Returns statement position which is the closest to
12908 // source_position. 12909 // source_position.
12909 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) { 12910 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) {
12910 CHECK(isolate->debugger()->live_edit_enabled()); 12911 CHECK(isolate->debugger()->live_edit_enabled());
12911 ASSERT(args.length() == 2); 12912 ASSERT(args.length() == 2);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
13080 // Capture a simple stack trace for the stack property. 13081 // Capture a simple stack trace for the stack property.
13081 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); 13082 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit);
13082 } 13083 }
13083 13084
13084 13085
13085 // Mark a function to recognize when called after GC to format the stack trace. 13086 // Mark a function to recognize when called after GC to format the stack trace.
13086 RUNTIME_FUNCTION(MaybeObject*, Runtime_MarkOneShotGetter) { 13087 RUNTIME_FUNCTION(MaybeObject*, Runtime_MarkOneShotGetter) {
13087 ASSERT_EQ(args.length(), 1); 13088 ASSERT_EQ(args.length(), 1);
13088 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 13089 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
13089 HandleScope scope(isolate); 13090 HandleScope scope(isolate);
13090 Handle<String> key = isolate->factory()->hidden_stack_trace_symbol(); 13091 Handle<String> key = isolate->factory()->hidden_stack_trace_string();
13091 JSObject::SetHiddenProperty(fun, key, key); 13092 JSObject::SetHiddenProperty(fun, key, key);
13092 return *fun; 13093 return *fun;
13093 } 13094 }
13094 13095
13095 13096
13096 // Retrieve the stack trace. This could be the raw stack trace collected 13097 // Retrieve the stack trace. This could be the raw stack trace collected
13097 // on stack overflow or the already formatted stack trace string. 13098 // on stack overflow or the already formatted stack trace string.
13098 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOverflowedStackTrace) { 13099 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOverflowedStackTrace) {
13099 HandleScope scope(isolate); 13100 HandleScope scope(isolate);
13100 ASSERT_EQ(args.length(), 1); 13101 ASSERT_EQ(args.length(), 1);
13101 CONVERT_ARG_CHECKED(JSObject, error_object, 0); 13102 CONVERT_ARG_CHECKED(JSObject, error_object, 0);
13102 String* key = isolate->heap()->hidden_stack_trace_symbol(); 13103 String* key = isolate->heap()->hidden_stack_trace_string();
13103 Object* result = error_object->GetHiddenProperty(key); 13104 Object* result = error_object->GetHiddenProperty(key);
13104 RUNTIME_ASSERT(result->IsJSArray() || 13105 RUNTIME_ASSERT(result->IsJSArray() ||
13105 result->IsString() || 13106 result->IsString() ||
13106 result->IsUndefined()); 13107 result->IsUndefined());
13107 return result; 13108 return result;
13108 } 13109 }
13109 13110
13110 13111
13111 // Set or clear the stack trace attached to an stack overflow error object. 13112 // Set or clear the stack trace attached to an stack overflow error object.
13112 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetOverflowedStackTrace) { 13113 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetOverflowedStackTrace) {
13113 HandleScope scope(isolate); 13114 HandleScope scope(isolate);
13114 ASSERT_EQ(args.length(), 2); 13115 ASSERT_EQ(args.length(), 2);
13115 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); 13116 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0);
13116 CONVERT_ARG_HANDLE_CHECKED(HeapObject, value, 1); 13117 CONVERT_ARG_HANDLE_CHECKED(HeapObject, value, 1);
13117 Handle<String> key = isolate->factory()->hidden_stack_trace_symbol(); 13118 Handle<String> key = isolate->factory()->hidden_stack_trace_string();
13118 if (value->IsUndefined()) { 13119 if (value->IsUndefined()) {
13119 error_object->DeleteHiddenProperty(*key); 13120 error_object->DeleteHiddenProperty(*key);
13120 } else { 13121 } else {
13121 RUNTIME_ASSERT(value->IsString()); 13122 RUNTIME_ASSERT(value->IsString());
13122 JSObject::SetHiddenProperty(error_object, key, value); 13123 JSObject::SetHiddenProperty(error_object, key, value);
13123 } 13124 }
13124 return *error_object; 13125 return *error_object;
13125 } 13126 }
13126 13127
13127 13128
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
13466 INLINE_RUNTIME_FUNCTION_LIST(I) 13467 INLINE_RUNTIME_FUNCTION_LIST(I)
13467 }; 13468 };
13468 13469
13469 13470
13470 MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap, 13471 MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap,
13471 Object* dictionary) { 13472 Object* dictionary) {
13472 ASSERT(Isolate::Current()->heap() == heap); 13473 ASSERT(Isolate::Current()->heap() == heap);
13473 ASSERT(dictionary != NULL); 13474 ASSERT(dictionary != NULL);
13474 ASSERT(StringDictionary::cast(dictionary)->NumberOfElements() == 0); 13475 ASSERT(StringDictionary::cast(dictionary)->NumberOfElements() == 0);
13475 for (int i = 0; i < kNumFunctions; ++i) { 13476 for (int i = 0; i < kNumFunctions; ++i) {
13476 Object* name_symbol; 13477 Object* name_string;
13477 { MaybeObject* maybe_name_symbol = 13478 { MaybeObject* maybe_name_string =
13478 heap->LookupUtf8Symbol(kIntrinsicFunctions[i].name); 13479 heap->InternalizeUtf8String(kIntrinsicFunctions[i].name);
13479 if (!maybe_name_symbol->ToObject(&name_symbol)) return maybe_name_symbol; 13480 if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string;
13480 } 13481 }
13481 StringDictionary* string_dictionary = StringDictionary::cast(dictionary); 13482 StringDictionary* string_dictionary = StringDictionary::cast(dictionary);
13482 { MaybeObject* maybe_dictionary = string_dictionary->Add( 13483 { MaybeObject* maybe_dictionary = string_dictionary->Add(
13483 String::cast(name_symbol), 13484 String::cast(name_string),
13484 Smi::FromInt(i), 13485 Smi::FromInt(i),
13485 PropertyDetails(NONE, NORMAL)); 13486 PropertyDetails(NONE, NORMAL));
13486 if (!maybe_dictionary->ToObject(&dictionary)) { 13487 if (!maybe_dictionary->ToObject(&dictionary)) {
13487 // Non-recoverable failure. Calling code must restart heap 13488 // Non-recoverable failure. Calling code must restart heap
13488 // initialization. 13489 // initialization.
13489 return maybe_dictionary; 13490 return maybe_dictionary;
13490 } 13491 }
13491 } 13492 }
13492 } 13493 }
13493 return dictionary; 13494 return dictionary;
13494 } 13495 }
13495 13496
13496 13497
13497 const Runtime::Function* Runtime::FunctionForSymbol(Handle<String> name) { 13498 const Runtime::Function* Runtime::FunctionForName(Handle<String> name) {
13498 Heap* heap = name->GetHeap(); 13499 Heap* heap = name->GetHeap();
13499 int entry = heap->intrinsic_function_names()->FindEntry(*name); 13500 int entry = heap->intrinsic_function_names()->FindEntry(*name);
13500 if (entry != kNotFound) { 13501 if (entry != kNotFound) {
13501 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry); 13502 Object* smi_index = heap->intrinsic_function_names()->ValueAt(entry);
13502 int function_index = Smi::cast(smi_index)->value(); 13503 int function_index = Smi::cast(smi_index)->value();
13503 return &(kIntrinsicFunctions[function_index]); 13504 return &(kIntrinsicFunctions[function_index]);
13504 } 13505 }
13505 return NULL; 13506 return NULL;
13506 } 13507 }
13507 13508
(...skipping 19 matching lines...) Expand all
13527 // Handle last resort GC and make sure to allow future allocations 13528 // Handle last resort GC and make sure to allow future allocations
13528 // to grow the heap without causing GCs (if possible). 13529 // to grow the heap without causing GCs (if possible).
13529 isolate->counters()->gc_last_resort_from_js()->Increment(); 13530 isolate->counters()->gc_last_resort_from_js()->Increment();
13530 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13531 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13531 "Runtime::PerformGC"); 13532 "Runtime::PerformGC");
13532 } 13533 }
13533 } 13534 }
13534 13535
13535 13536
13536 } } // namespace v8::internal 13537 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698