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

Side by Side Diff: src/runtime.cc

Issue 6577036: [Isolates] Merge from bleeding_edge to isolates, revisions 6100-6300. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 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/runtime.js » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 if (value->IsFixedArray()) { 332 if (value->IsFixedArray()) {
333 // The value contains the constant_properties of a 333 // The value contains the constant_properties of a
334 // simple object literal. 334 // simple object literal.
335 Handle<FixedArray> array = Handle<FixedArray>::cast(value); 335 Handle<FixedArray> array = Handle<FixedArray>::cast(value);
336 value = CreateLiteralBoilerplate(isolate, literals, array); 336 value = CreateLiteralBoilerplate(isolate, literals, array);
337 if (value.is_null()) return value; 337 if (value.is_null()) return value;
338 } 338 }
339 Handle<Object> result; 339 Handle<Object> result;
340 uint32_t element_index = 0; 340 uint32_t element_index = 0;
341 if (key->IsSymbol()) { 341 if (key->IsSymbol()) {
342 // If key is a symbol it is not an array element. 342 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
343 Handle<String> name(String::cast(*key)); 343 // Array index as string (uint32).
344 ASSERT(!name->AsArrayIndex(&element_index)); 344 result = SetOwnElement(boilerplate, element_index, value);
345 result = SetProperty(boilerplate, name, value, NONE); 345 } else {
346 Handle<String> name(String::cast(*key));
347 ASSERT(!name->AsArrayIndex(&element_index));
348 result = SetLocalPropertyIgnoreAttributes(boilerplate, name,
349 value, NONE);
350 }
346 } else if (key->ToArrayIndex(&element_index)) { 351 } else if (key->ToArrayIndex(&element_index)) {
347 // Array index (uint32). 352 // Array index (uint32).
348 result = SetElement(boilerplate, element_index, value); 353 result = SetOwnElement(boilerplate, element_index, value);
349 } else { 354 } else {
350 // Non-uint32 number. 355 // Non-uint32 number.
351 ASSERT(key->IsNumber()); 356 ASSERT(key->IsNumber());
352 double num = key->Number(); 357 double num = key->Number();
353 char arr[100]; 358 char arr[100];
354 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 359 Vector<char> buffer(arr, ARRAY_SIZE(arr));
355 const char* str = DoubleToCString(num, buffer); 360 const char* str = DoubleToCString(num, buffer);
356 Handle<String> name = 361 Handle<String> name =
357 isolate->factory()->NewStringFromAscii(CStrVector(str)); 362 isolate->factory()->NewStringFromAscii(CStrVector(str));
358 result = SetProperty(boilerplate, name, value, NONE); 363 result = SetLocalPropertyIgnoreAttributes(boilerplate, name,
364 value, NONE);
359 } 365 }
360 // If setting the property on the boilerplate throws an 366 // If setting the property on the boilerplate throws an
361 // exception, the exception is converted to an empty handle in 367 // exception, the exception is converted to an empty handle in
362 // the handle based operations. In that case, we need to 368 // the handle based operations. In that case, we need to
363 // convert back to an exception. 369 // convert back to an exception.
364 if (result.is_null()) return result; 370 if (result.is_null()) return result;
365 } 371 }
366 } 372 }
367 373
368 return boilerplate; 374 return boilerplate;
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 return ThrowRedeclarationError(isolate, type, name); 1032 return ThrowRedeclarationError(isolate, type, name);
1027 } 1033 }
1028 SetProperty(global, name, value, attributes); 1034 SetProperty(global, name, value, attributes);
1029 } else { 1035 } else {
1030 // If a property with this name does not already exist on the 1036 // If a property with this name does not already exist on the
1031 // global object add the property locally. We take special 1037 // global object add the property locally. We take special
1032 // precautions to always add it as a local property even in case 1038 // precautions to always add it as a local property even in case
1033 // of callbacks in the prototype chain (this rules out using 1039 // of callbacks in the prototype chain (this rules out using
1034 // SetProperty). Also, we must use the handle-based version to 1040 // SetProperty). Also, we must use the handle-based version to
1035 // avoid GC issues. 1041 // avoid GC issues.
1036 IgnoreAttributesAndSetLocalProperty(global, name, value, attributes); 1042 SetLocalPropertyIgnoreAttributes(global, name, value, attributes);
1037 } 1043 }
1038 } 1044 }
1039 1045
1040 return isolate->heap()->undefined_value(); 1046 return isolate->heap()->undefined_value();
1041 } 1047 }
1042 1048
1043 1049
1044 static MaybeObject* Runtime_DeclareContextSlot(RUNTIME_CALLING_CONVENTION) { 1050 static MaybeObject* Runtime_DeclareContextSlot(RUNTIME_CALLING_CONVENTION) {
1045 RUNTIME_GET_ISOLATE; 1051 RUNTIME_GET_ISOLATE;
1046 HandleScope scope(isolate); 1052 HandleScope scope(isolate);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 // not be deletable. 1150 // not be deletable.
1145 PropertyAttributes attributes = DONT_DELETE; 1151 PropertyAttributes attributes = DONT_DELETE;
1146 1152
1147 // Lookup the property locally in the global object. If it isn't 1153 // Lookup the property locally in the global object. If it isn't
1148 // there, there is a property with this name in the prototype chain. 1154 // there, there is a property with this name in the prototype chain.
1149 // We follow Safari and Firefox behavior and only set the property 1155 // We follow Safari and Firefox behavior and only set the property
1150 // locally if there is an explicit initialization value that we have 1156 // locally if there is an explicit initialization value that we have
1151 // to assign to the property. When adding the property we take 1157 // to assign to the property. When adding the property we take
1152 // special precautions to always add it as a local property even in 1158 // special precautions to always add it as a local property even in
1153 // case of callbacks in the prototype chain (this rules out using 1159 // case of callbacks in the prototype chain (this rules out using
1154 // SetProperty). We have IgnoreAttributesAndSetLocalProperty for 1160 // SetProperty). We have SetLocalPropertyIgnoreAttributes for
1155 // this. 1161 // this.
1156 // Note that objects can have hidden prototypes, so we need to traverse 1162 // Note that objects can have hidden prototypes, so we need to traverse
1157 // the whole chain of hidden prototypes to do a 'local' lookup. 1163 // the whole chain of hidden prototypes to do a 'local' lookup.
1158 JSObject* real_holder = global; 1164 JSObject* real_holder = global;
1159 LookupResult lookup; 1165 LookupResult lookup;
1160 while (true) { 1166 while (true) {
1161 real_holder->LocalLookup(*name, &lookup); 1167 real_holder->LocalLookup(*name, &lookup);
1162 if (lookup.IsProperty()) { 1168 if (lookup.IsProperty()) {
1163 // Determine if this is a redeclaration of something read-only. 1169 // Determine if this is a redeclaration of something read-only.
1164 if (lookup.IsReadOnly()) { 1170 if (lookup.IsReadOnly()) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 break; 1213 break;
1208 1214
1209 if (!JSObject::cast(proto)->map()->is_hidden_prototype()) 1215 if (!JSObject::cast(proto)->map()->is_hidden_prototype())
1210 break; 1216 break;
1211 1217
1212 real_holder = JSObject::cast(proto); 1218 real_holder = JSObject::cast(proto);
1213 } 1219 }
1214 1220
1215 global = isolate->context()->global(); 1221 global = isolate->context()->global();
1216 if (assign) { 1222 if (assign) {
1217 return global->IgnoreAttributesAndSetLocalProperty(*name, 1223 return global->SetLocalPropertyIgnoreAttributes(*name,
1218 args[1], 1224 args[1],
1219 attributes); 1225 attributes);
1220 } 1226 }
1221 return isolate->heap()->undefined_value(); 1227 return isolate->heap()->undefined_value();
1222 } 1228 }
1223 1229
1224 1230
1225 static MaybeObject* Runtime_InitializeConstGlobal(RUNTIME_CALLING_CONVENTION) { 1231 static MaybeObject* Runtime_InitializeConstGlobal(RUNTIME_CALLING_CONVENTION) {
1226 RUNTIME_GET_ISOLATE; 1232 RUNTIME_GET_ISOLATE;
1227 // All constants are declared with an initial value. The name 1233 // All constants are declared with an initial value. The name
1228 // of the constant is the first argument and the initial value 1234 // of the constant is the first argument and the initial value
1229 // is the second. 1235 // is the second.
1230 RUNTIME_ASSERT(args.length() == 2); 1236 RUNTIME_ASSERT(args.length() == 2);
1231 CONVERT_ARG_CHECKED(String, name, 0); 1237 CONVERT_ARG_CHECKED(String, name, 0);
1232 Handle<Object> value = args.at<Object>(1); 1238 Handle<Object> value = args.at<Object>(1);
1233 1239
1234 // Get the current global object from top. 1240 // Get the current global object from top.
1235 GlobalObject* global = isolate->context()->global(); 1241 GlobalObject* global = isolate->context()->global();
1236 1242
1237 // According to ECMA-262, section 12.2, page 62, the property must 1243 // According to ECMA-262, section 12.2, page 62, the property must
1238 // not be deletable. Since it's a const, it must be READ_ONLY too. 1244 // not be deletable. Since it's a const, it must be READ_ONLY too.
1239 PropertyAttributes attributes = 1245 PropertyAttributes attributes =
1240 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 1246 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
1241 1247
1242 // Lookup the property locally in the global object. If it isn't 1248 // Lookup the property locally in the global object. If it isn't
1243 // there, we add the property and take special precautions to always 1249 // there, we add the property and take special precautions to always
1244 // add it as a local property even in case of callbacks in the 1250 // add it as a local property even in case of callbacks in the
1245 // prototype chain (this rules out using SetProperty). 1251 // prototype chain (this rules out using SetProperty).
1246 // We use IgnoreAttributesAndSetLocalProperty instead 1252 // We use SetLocalPropertyIgnoreAttributes instead
1247 LookupResult lookup; 1253 LookupResult lookup;
1248 global->LocalLookup(*name, &lookup); 1254 global->LocalLookup(*name, &lookup);
1249 if (!lookup.IsProperty()) { 1255 if (!lookup.IsProperty()) {
1250 return global->IgnoreAttributesAndSetLocalProperty(*name, 1256 return global->SetLocalPropertyIgnoreAttributes(*name,
1251 *value, 1257 *value,
1252 attributes); 1258 attributes);
1253 } 1259 }
1254 1260
1255 // Determine if this is a redeclaration of something not 1261 // Determine if this is a redeclaration of something not
1256 // read-only. In case the result is hidden behind an interceptor we 1262 // read-only. In case the result is hidden behind an interceptor we
1257 // need to ask it for the property attributes. 1263 // need to ask it for the property attributes.
1258 if (!lookup.IsReadOnly()) { 1264 if (!lookup.IsReadOnly()) {
1259 if (lookup.type() != INTERCEPTOR) { 1265 if (lookup.type() != INTERCEPTOR) {
1260 return ThrowRedeclarationError(isolate, "var", name); 1266 return ThrowRedeclarationError(isolate, "var", name);
1261 } 1267 }
1262 1268
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 return regexp; 1524 return regexp;
1519 } 1525 }
1520 1526
1521 // Map has changed, so use generic, but slower, method. 1527 // Map has changed, so use generic, but slower, method.
1522 PropertyAttributes final = 1528 PropertyAttributes final =
1523 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); 1529 static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE);
1524 PropertyAttributes writable = 1530 PropertyAttributes writable =
1525 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); 1531 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
1526 Heap* heap = isolate->heap(); 1532 Heap* heap = isolate->heap();
1527 MaybeObject* result; 1533 MaybeObject* result;
1528 result = regexp->IgnoreAttributesAndSetLocalProperty(heap->source_symbol(), 1534 result = regexp->SetLocalPropertyIgnoreAttributes(heap->source_symbol(),
1529 source, 1535 source,
1530 final); 1536 final);
1531 ASSERT(!result->IsFailure()); 1537 ASSERT(!result->IsFailure());
1532 result = regexp->IgnoreAttributesAndSetLocalProperty(heap->global_symbol(), 1538 result = regexp->SetLocalPropertyIgnoreAttributes(heap->global_symbol(),
1533 global, 1539 global,
1534 final); 1540 final);
1535 ASSERT(!result->IsFailure()); 1541 ASSERT(!result->IsFailure());
1536 result = 1542 result =
1537 regexp->IgnoreAttributesAndSetLocalProperty(heap->ignore_case_symbol(), 1543 regexp->SetLocalPropertyIgnoreAttributes(heap->ignore_case_symbol(),
1538 ignoreCase, 1544 ignoreCase,
1539 final); 1545 final);
1540 ASSERT(!result->IsFailure()); 1546 ASSERT(!result->IsFailure());
1541 result = regexp->IgnoreAttributesAndSetLocalProperty(heap->multiline_symbol(), 1547 result = regexp->SetLocalPropertyIgnoreAttributes(heap->multiline_symbol(),
1542 multiline, 1548 multiline,
1543 final); 1549 final);
1544 ASSERT(!result->IsFailure()); 1550 ASSERT(!result->IsFailure());
1545 result = 1551 result =
1546 regexp->IgnoreAttributesAndSetLocalProperty(heap->last_index_symbol(), 1552 regexp->SetLocalPropertyIgnoreAttributes(heap->last_index_symbol(),
1547 Smi::FromInt(0), 1553 Smi::FromInt(0),
1548 writable); 1554 writable);
1549 ASSERT(!result->IsFailure()); 1555 ASSERT(!result->IsFailure());
1550 USE(result); 1556 USE(result);
1551 return regexp; 1557 return regexp;
1552 } 1558 }
1553 1559
1554 1560
1555 static MaybeObject* Runtime_FinishArrayPrototypeSetup( 1561 static MaybeObject* Runtime_FinishArrayPrototypeSetup(
1556 RUNTIME_CALLING_CONVENTION) { 1562 RUNTIME_CALLING_CONVENTION) {
1557 RUNTIME_GET_ISOLATE; 1563 RUNTIME_GET_ISOLATE;
1558 HandleScope scope(isolate); 1564 HandleScope scope(isolate);
(...skipping 2165 matching lines...) Expand 10 before | Expand all | Expand 10 after
3724 // to not worry about changing the instance_descriptor and creating a new 3730 // to not worry about changing the instance_descriptor and creating a new
3725 // map. The current version of SetObjectProperty does not handle attributes 3731 // map. The current version of SetObjectProperty does not handle attributes
3726 // correctly in the case where a property is a field and is reset with 3732 // correctly in the case where a property is a field and is reset with
3727 // new attributes. 3733 // new attributes.
3728 if (result.IsProperty() && 3734 if (result.IsProperty() &&
3729 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { 3735 (attr != result.GetAttributes() || result.type() == CALLBACKS)) {
3730 // New attributes - normalize to avoid writing to instance descriptor 3736 // New attributes - normalize to avoid writing to instance descriptor
3731 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); 3737 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0);
3732 // Use IgnoreAttributes version since a readonly property may be 3738 // Use IgnoreAttributes version since a readonly property may be
3733 // overridden and SetProperty does not allow this. 3739 // overridden and SetProperty does not allow this.
3734 return js_object->IgnoreAttributesAndSetLocalProperty(*name, 3740 return js_object->SetLocalPropertyIgnoreAttributes(*name,
3735 *obj_value, 3741 *obj_value,
3736 attr); 3742 attr);
3737 } 3743 }
3738 3744
3739 return Runtime::SetObjectProperty(isolate, js_object, name, obj_value, attr); 3745 return Runtime::SetObjectProperty(isolate, js_object, name, obj_value, attr);
3740 } 3746 }
3741 3747
3742 3748
3743 MaybeObject* Runtime::SetObjectProperty(Isolate* isolate, 3749 MaybeObject* Runtime::SetObjectProperty(Isolate* isolate,
3744 Handle<Object> object, 3750 Handle<Object> object,
3745 Handle<Object> key, 3751 Handle<Object> key,
3746 Handle<Object> value, 3752 Handle<Object> value,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
3829 3835
3830 return js_object->SetElement(index, *value); 3836 return js_object->SetElement(index, *value);
3831 } 3837 }
3832 3838
3833 if (key->IsString()) { 3839 if (key->IsString()) {
3834 if (Handle<String>::cast(key)->AsArrayIndex(&index)) { 3840 if (Handle<String>::cast(key)->AsArrayIndex(&index)) {
3835 return js_object->SetElement(index, *value); 3841 return js_object->SetElement(index, *value);
3836 } else { 3842 } else {
3837 Handle<String> key_string = Handle<String>::cast(key); 3843 Handle<String> key_string = Handle<String>::cast(key);
3838 key_string->TryFlatten(); 3844 key_string->TryFlatten();
3839 return js_object->IgnoreAttributesAndSetLocalProperty(*key_string, 3845 return js_object->SetLocalPropertyIgnoreAttributes(*key_string,
3840 *value, 3846 *value,
3841 attr); 3847 attr);
3842 } 3848 }
3843 } 3849 }
3844 3850
3845 // Call-back into JavaScript to convert the key to a string. 3851 // Call-back into JavaScript to convert the key to a string.
3846 bool has_pending_exception = false; 3852 bool has_pending_exception = false;
3847 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); 3853 Handle<Object> converted = Execution::ToString(key, &has_pending_exception);
3848 if (has_pending_exception) return Failure::Exception(); 3854 if (has_pending_exception) return Failure::Exception();
3849 Handle<String> name = Handle<String>::cast(converted); 3855 Handle<String> name = Handle<String>::cast(converted);
3850 3856
3851 if (name->AsArrayIndex(&index)) { 3857 if (name->AsArrayIndex(&index)) {
3852 return js_object->SetElement(index, *value); 3858 return js_object->SetElement(index, *value);
3853 } else { 3859 } else {
3854 return js_object->IgnoreAttributesAndSetLocalProperty(*name, *value, attr); 3860 return js_object->SetLocalPropertyIgnoreAttributes(*name, *value, attr);
3855 } 3861 }
3856 } 3862 }
3857 3863
3858 3864
3859 MaybeObject* Runtime::ForceDeleteObjectProperty(Isolate* isolate, 3865 MaybeObject* Runtime::ForceDeleteObjectProperty(Isolate* isolate,
3860 Handle<JSObject> js_object, 3866 Handle<JSObject> js_object,
3861 Handle<Object> key) { 3867 Handle<Object> key) {
3862 HandleScope scope(isolate); 3868 HandleScope scope(isolate);
3863 3869
3864 // Check if the given key is an array index. 3870 // Check if the given key is an array index.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3930 if (args.length() == 4) { 3936 if (args.length() == 4) {
3931 CONVERT_CHECKED(Smi, value_obj, args[3]); 3937 CONVERT_CHECKED(Smi, value_obj, args[3]);
3932 int unchecked_value = value_obj->value(); 3938 int unchecked_value = value_obj->value();
3933 // Only attribute bits should be set. 3939 // Only attribute bits should be set.
3934 RUNTIME_ASSERT( 3940 RUNTIME_ASSERT(
3935 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 3941 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
3936 attributes = static_cast<PropertyAttributes>(unchecked_value); 3942 attributes = static_cast<PropertyAttributes>(unchecked_value);
3937 } 3943 }
3938 3944
3939 return object-> 3945 return object->
3940 IgnoreAttributesAndSetLocalProperty(name, args[2], attributes); 3946 SetLocalPropertyIgnoreAttributes(name, args[2], attributes);
3941 } 3947 }
3942 3948
3943 3949
3944 static MaybeObject* Runtime_DeleteProperty(RUNTIME_CALLING_CONVENTION) { 3950 static MaybeObject* Runtime_DeleteProperty(RUNTIME_CALLING_CONVENTION) {
3945 RUNTIME_GET_ISOLATE; 3951 RUNTIME_GET_ISOLATE;
3946 NoHandleAllocation ha; 3952 NoHandleAllocation ha;
3947 ASSERT(args.length() == 2); 3953 ASSERT(args.length() == 2);
3948 3954
3949 CONVERT_CHECKED(JSObject, object, args[0]); 3955 CONVERT_CHECKED(JSObject, object, args[0]);
3950 CONVERT_CHECKED(String, key, args[1]); 3956 CONVERT_CHECKED(String, key, args[1]);
(...skipping 3079 matching lines...) Expand 10 before | Expand all | Expand 10 after
7030 if (i != 0) it.Advance(); 7036 if (i != 0) it.Advance();
7031 frame = it.frame(); 7037 frame = it.frame();
7032 deoptimizer->InsertHeapNumberValues(frames - i - 1, frame); 7038 deoptimizer->InsertHeapNumberValues(frames - i - 1, frame);
7033 } 7039 }
7034 delete deoptimizer; 7040 delete deoptimizer;
7035 7041
7036 RUNTIME_ASSERT(frame->function()->IsJSFunction()); 7042 RUNTIME_ASSERT(frame->function()->IsJSFunction());
7037 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate); 7043 Handle<JSFunction> function(JSFunction::cast(frame->function()), isolate);
7038 Handle<Object> arguments; 7044 Handle<Object> arguments;
7039 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) { 7045 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
7040 if (frame->GetExpression(i) == isolate->heap()->the_hole_value()) { 7046 if (frame->GetExpression(i) == isolate->heap()->arguments_marker()) {
7041 if (arguments.is_null()) { 7047 if (arguments.is_null()) {
7042 // FunctionGetArguments can't throw an exception, so cast away the 7048 // FunctionGetArguments can't throw an exception, so cast away the
7043 // doubt with an assert. 7049 // doubt with an assert.
7044 arguments = Handle<Object>( 7050 arguments = Handle<Object>(
7045 Accessors::FunctionGetArguments(*function, 7051 Accessors::FunctionGetArguments(*function,
7046 NULL)->ToObjectUnchecked()); 7052 NULL)->ToObjectUnchecked());
7047 ASSERT(*arguments != isolate->heap()->null_value()); 7053 ASSERT(*arguments != isolate->heap()->null_value());
7048 ASSERT(*arguments != isolate->heap()->undefined_value()); 7054 ASSERT(*arguments != isolate->heap()->undefined_value());
7049 } 7055 }
7050 frame->SetExpression(i, *arguments); 7056 frame->SetExpression(i, *arguments);
(...skipping 3737 matching lines...) Expand 10 before | Expand all | Expand 10 after
10788 RUNTIME_CALLING_CONVENTION) { 10794 RUNTIME_CALLING_CONVENTION) {
10789 RUNTIME_GET_ISOLATE; 10795 RUNTIME_GET_ISOLATE;
10790 ASSERT(args.length() == 2); 10796 ASSERT(args.length() == 2);
10791 HandleScope scope(isolate); 10797 HandleScope scope(isolate);
10792 CONVERT_ARG_CHECKED(JSArray, shared_array, 0); 10798 CONVERT_ARG_CHECKED(JSArray, shared_array, 0);
10793 CONVERT_BOOLEAN_CHECKED(do_drop, args[1]); 10799 CONVERT_BOOLEAN_CHECKED(do_drop, args[1]);
10794 10800
10795 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); 10801 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop);
10796 } 10802 }
10797 10803
10798 // Compares 2 strings line-by-line and returns diff in form of JSArray of 10804 // Compares 2 strings line-by-line, then token-wise and returns diff in form
10799 // triplets (pos1, pos1_end, pos2_end) describing list of diff chunks. 10805 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list
10800 static MaybeObject* Runtime_LiveEditCompareStringsLinewise( 10806 // of diff chunks.
10801 RUNTIME_CALLING_CONVENTION) { 10807 static MaybeObject* Runtime_LiveEditCompareStrings(RUNTIME_CALLING_CONVENTION) {
10802 RUNTIME_GET_ISOLATE; 10808 RUNTIME_GET_ISOLATE;
10803 ASSERT(args.length() == 2); 10809 ASSERT(args.length() == 2);
10804 HandleScope scope(isolate); 10810 HandleScope scope(isolate);
10805 CONVERT_ARG_CHECKED(String, s1, 0); 10811 CONVERT_ARG_CHECKED(String, s1, 0);
10806 CONVERT_ARG_CHECKED(String, s2, 1); 10812 CONVERT_ARG_CHECKED(String, s2, 1);
10807 10813
10808 return *LiveEdit::CompareStringsLinewise(s1, s2); 10814 return *LiveEdit::CompareStrings(s1, s2);
10809 } 10815 }
10810 10816
10811 10817
10812 // A testing entry. Returns statement position which is the closest to 10818 // A testing entry. Returns statement position which is the closest to
10813 // source_position. 10819 // source_position.
10814 static MaybeObject* Runtime_GetFunctionCodePositionFromSource( 10820 static MaybeObject* Runtime_GetFunctionCodePositionFromSource(
10815 RUNTIME_CALLING_CONVENTION) { 10821 RUNTIME_CALLING_CONVENTION) {
10816 RUNTIME_GET_ISOLATE; 10822 RUNTIME_GET_ISOLATE;
10817 ASSERT(args.length() == 2); 10823 ASSERT(args.length() == 2);
10818 HandleScope scope(isolate); 10824 HandleScope scope(isolate);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
10870 } 10876 }
10871 } 10877 }
10872 if (!pending_exception) { 10878 if (!pending_exception) {
10873 return *result; 10879 return *result;
10874 } else { 10880 } else {
10875 return Failure::Exception(); 10881 return Failure::Exception();
10876 } 10882 }
10877 } 10883 }
10878 10884
10879 10885
10886 // Sets a v8 flag.
10887 static MaybeObject* Runtime_SetFlags(RUNTIME_CALLING_CONVENTION) {
10888 RUNTIME_GET_ISOLATE;
10889 CONVERT_CHECKED(String, arg, args[0]);
10890 SmartPointer<char> flags =
10891 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
10892 FlagList::SetFlagsFromString(*flags, StrLength(*flags));
10893 return isolate->heap()->undefined_value();
10894 }
10895
10896
10897 // Performs a GC.
10898 // Presently, it only does a full GC.
10899 static MaybeObject* Runtime_CollectGarbage(RUNTIME_CALLING_CONVENTION) {
10900 RUNTIME_GET_ISOLATE;
10901 isolate->heap()->CollectAllGarbage(true);
10902 return isolate->heap()->undefined_value();
10903 }
10904
10905
10906 // Gets the current heap usage.
10907 static MaybeObject* Runtime_GetHeapUsage(RUNTIME_CALLING_CONVENTION) {
10908 RUNTIME_GET_ISOLATE;
10909 int usage = static_cast<int>(isolate->heap()->SizeOfObjects());
10910 if (!Smi::IsValid(usage)) {
10911 return *isolate->factory()->NewNumberFromInt(usage);
10912 }
10913 return Smi::FromInt(usage);
10914 }
10880 #endif // ENABLE_DEBUGGER_SUPPORT 10915 #endif // ENABLE_DEBUGGER_SUPPORT
10881 10916
10917
10882 #ifdef ENABLE_LOGGING_AND_PROFILING 10918 #ifdef ENABLE_LOGGING_AND_PROFILING
10883
10884 static MaybeObject* Runtime_ProfilerResume(RUNTIME_CALLING_CONVENTION) { 10919 static MaybeObject* Runtime_ProfilerResume(RUNTIME_CALLING_CONVENTION) {
10885 RUNTIME_GET_ISOLATE; 10920 RUNTIME_GET_ISOLATE;
10886 NoHandleAllocation ha; 10921 NoHandleAllocation ha;
10887 ASSERT(args.length() == 2); 10922 ASSERT(args.length() == 2);
10888 10923
10889 CONVERT_CHECKED(Smi, smi_modules, args[0]); 10924 CONVERT_CHECKED(Smi, smi_modules, args[0]);
10890 CONVERT_CHECKED(Smi, smi_tag, args[1]); 10925 CONVERT_CHECKED(Smi, smi_tag, args[1]);
10891 v8::V8::ResumeProfilerEx(smi_modules->value(), smi_tag->value()); 10926 v8::V8::ResumeProfilerEx(smi_modules->value(), smi_tag->value());
10892 return isolate->heap()->undefined_value(); 10927 return isolate->heap()->undefined_value();
10893 } 10928 }
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
11281 } else { 11316 } else {
11282 // Handle last resort GC and make sure to allow future allocations 11317 // Handle last resort GC and make sure to allow future allocations
11283 // to grow the heap without causing GCs (if possible). 11318 // to grow the heap without causing GCs (if possible).
11284 COUNTERS->gc_last_resort_from_js()->Increment(); 11319 COUNTERS->gc_last_resort_from_js()->Increment();
11285 HEAP->CollectAllGarbage(false); 11320 HEAP->CollectAllGarbage(false);
11286 } 11321 }
11287 } 11322 }
11288 11323
11289 11324
11290 } } // namespace v8::internal 11325 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | src/runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698