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 177683002: Mode clean-up pt 1: rename classic/non-strict mode to sloppy mode (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 #define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \ 151 #define CONVERT_PROPERTY_DETAILS_CHECKED(name, index) \
152 RUNTIME_ASSERT(args[index]->IsSmi()); \ 152 RUNTIME_ASSERT(args[index]->IsSmi()); \
153 PropertyDetails name = PropertyDetails(Smi::cast(args[index])); 153 PropertyDetails name = PropertyDetails(Smi::cast(args[index]));
154 154
155 155
156 // Assert that the given argument has a valid value for a StrictModeFlag 156 // Assert that the given argument has a valid value for a StrictModeFlag
157 // and store it in a StrictModeFlag variable with the given name. 157 // and store it in a StrictModeFlag variable with the given name.
158 #define CONVERT_STRICT_MODE_ARG_CHECKED(name, index) \ 158 #define CONVERT_STRICT_MODE_ARG_CHECKED(name, index) \
159 RUNTIME_ASSERT(args[index]->IsSmi()); \ 159 RUNTIME_ASSERT(args[index]->IsSmi()); \
160 RUNTIME_ASSERT(args.smi_at(index) == kStrictMode || \ 160 RUNTIME_ASSERT(args.smi_at(index) == kStrictMode || \
161 args.smi_at(index) == kNonStrictMode); \ 161 args.smi_at(index) == kSloppyMode); \
162 StrictModeFlag name = \ 162 StrictModeFlag name = \
163 static_cast<StrictModeFlag>(args.smi_at(index)); 163 static_cast<StrictModeFlag>(args.smi_at(index));
164 164
165 165
166 // Assert that the given argument has a valid value for a LanguageMode 166 // Assert that the given argument has a valid value for a LanguageMode
167 // and store it in a LanguageMode variable with the given name. 167 // and store it in a LanguageMode variable with the given name.
168 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \ 168 #define CONVERT_LANGUAGE_MODE_ARG(name, index) \
169 ASSERT(args[index]->IsSmi()); \ 169 ASSERT(args[index]->IsSmi()); \
170 ASSERT(args.smi_at(index) == CLASSIC_MODE || \ 170 ASSERT(args.smi_at(index) == SLOPPY_MODE || \
171 args.smi_at(index) == STRICT_MODE || \ 171 args.smi_at(index) == STRICT_MODE || \
172 args.smi_at(index) == EXTENDED_MODE); \ 172 args.smi_at(index) == EXTENDED_MODE); \
173 LanguageMode name = \ 173 LanguageMode name = \
174 static_cast<LanguageMode>(args.smi_at(index)); 174 static_cast<LanguageMode>(args.smi_at(index));
175 175
176 176
177 static Handle<Map> ComputeObjectLiteralMap( 177 static Handle<Map> ComputeObjectLiteralMap(
178 Handle<Context> context, 178 Handle<Context> context,
179 Handle<FixedArray> constant_properties, 179 Handle<FixedArray> constant_properties,
180 bool* is_result_from_cache) { 180 bool* is_result_from_cache) {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 value = CreateLiteralBoilerplate(isolate, literals, array); 291 value = CreateLiteralBoilerplate(isolate, literals, array);
292 if (value.is_null()) return value; 292 if (value.is_null()) return value;
293 } 293 }
294 Handle<Object> result; 294 Handle<Object> result;
295 uint32_t element_index = 0; 295 uint32_t element_index = 0;
296 StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT; 296 StoreMode mode = value->IsJSObject() ? FORCE_FIELD : ALLOW_AS_CONSTANT;
297 if (key->IsInternalizedString()) { 297 if (key->IsInternalizedString()) {
298 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) { 298 if (Handle<String>::cast(key)->AsArrayIndex(&element_index)) {
299 // Array index as string (uint32). 299 // Array index as string (uint32).
300 result = JSObject::SetOwnElement( 300 result = JSObject::SetOwnElement(
301 boilerplate, element_index, value, kNonStrictMode); 301 boilerplate, element_index, value, kSloppyMode);
302 } else { 302 } else {
303 Handle<String> name(String::cast(*key)); 303 Handle<String> name(String::cast(*key));
304 ASSERT(!name->AsArrayIndex(&element_index)); 304 ASSERT(!name->AsArrayIndex(&element_index));
305 result = JSObject::SetLocalPropertyIgnoreAttributes( 305 result = JSObject::SetLocalPropertyIgnoreAttributes(
306 boilerplate, name, value, NONE, 306 boilerplate, name, value, NONE,
307 Object::OPTIMAL_REPRESENTATION, mode); 307 Object::OPTIMAL_REPRESENTATION, mode);
308 } 308 }
309 } else if (key->ToArrayIndex(&element_index)) { 309 } else if (key->ToArrayIndex(&element_index)) {
310 // Array index (uint32). 310 // Array index (uint32).
311 result = JSObject::SetOwnElement( 311 result = JSObject::SetOwnElement(
312 boilerplate, element_index, value, kNonStrictMode); 312 boilerplate, element_index, value, kSloppyMode);
313 } else { 313 } else {
314 // Non-uint32 number. 314 // Non-uint32 number.
315 ASSERT(key->IsNumber()); 315 ASSERT(key->IsNumber());
316 double num = key->Number(); 316 double num = key->Number();
317 char arr[100]; 317 char arr[100];
318 Vector<char> buffer(arr, ARRAY_SIZE(arr)); 318 Vector<char> buffer(arr, ARRAY_SIZE(arr));
319 const char* str = DoubleToCString(num, buffer); 319 const char* str = DoubleToCString(num, buffer);
320 Handle<String> name = 320 Handle<String> name =
321 isolate->factory()->NewStringFromAscii(CStrVector(str)); 321 isolate->factory()->NewStringFromAscii(CStrVector(str));
322 result = JSObject::SetLocalPropertyIgnoreAttributes( 322 result = JSObject::SetLocalPropertyIgnoreAttributes(
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after
2113 } 2113 }
2114 // Define or redefine own property. 2114 // Define or redefine own property.
2115 RETURN_IF_EMPTY_HANDLE(isolate, 2115 RETURN_IF_EMPTY_HANDLE(isolate,
2116 JSObject::SetLocalPropertyIgnoreAttributes( 2116 JSObject::SetLocalPropertyIgnoreAttributes(
2117 global, name, value, static_cast<PropertyAttributes>(attr))); 2117 global, name, value, static_cast<PropertyAttributes>(attr)));
2118 } else { 2118 } else {
2119 // Do a [[Put]] on the existing (own) property. 2119 // Do a [[Put]] on the existing (own) property.
2120 RETURN_IF_EMPTY_HANDLE(isolate, 2120 RETURN_IF_EMPTY_HANDLE(isolate,
2121 JSObject::SetProperty( 2121 JSObject::SetProperty(
2122 global, name, value, static_cast<PropertyAttributes>(attr), 2122 global, name, value, static_cast<PropertyAttributes>(attr),
2123 language_mode == CLASSIC_MODE ? kNonStrictMode : kStrictMode)); 2123 language_mode == SLOPPY_MODE ? kSloppyMode : kStrictMode));
2124 } 2124 }
2125 } 2125 }
2126 2126
2127 ASSERT(!isolate->has_pending_exception()); 2127 ASSERT(!isolate->has_pending_exception());
2128 return isolate->heap()->undefined_value(); 2128 return isolate->heap()->undefined_value();
2129 } 2129 }
2130 2130
2131 2131
2132 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) { 2132 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeclareContextSlot) {
2133 HandleScope scope(isolate); 2133 HandleScope scope(isolate);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 context->get(index)->IsTheHole()) { 2170 context->get(index)->IsTheHole()) {
2171 context->set(index, *initial_value); 2171 context->set(index, *initial_value);
2172 } 2172 }
2173 } else { 2173 } else {
2174 // Slow case: The property is in the context extension object of a 2174 // Slow case: The property is in the context extension object of a
2175 // function context or the global object of a native context. 2175 // function context or the global object of a native context.
2176 Handle<JSObject> object = Handle<JSObject>::cast(holder); 2176 Handle<JSObject> object = Handle<JSObject>::cast(holder);
2177 RETURN_IF_EMPTY_HANDLE( 2177 RETURN_IF_EMPTY_HANDLE(
2178 isolate, 2178 isolate,
2179 JSReceiver::SetProperty(object, name, initial_value, mode, 2179 JSReceiver::SetProperty(object, name, initial_value, mode,
2180 kNonStrictMode)); 2180 kSloppyMode));
2181 } 2181 }
2182 } 2182 }
2183 2183
2184 } else { 2184 } else {
2185 // The property is not in the function context. It needs to be 2185 // The property is not in the function context. It needs to be
2186 // "declared" in the function context's extension context or as a 2186 // "declared" in the function context's extension context or as a
2187 // property of the the global object. 2187 // property of the the global object.
2188 Handle<JSObject> object; 2188 Handle<JSObject> object;
2189 if (context->has_extension()) { 2189 if (context->has_extension()) {
2190 object = Handle<JSObject>(JSObject::cast(context->extension())); 2190 object = Handle<JSObject>(JSObject::cast(context->extension()));
(...skipping 25 matching lines...) Expand all
2216 if (lookup.IsPropertyCallbacks()) { 2216 if (lookup.IsPropertyCallbacks()) {
2217 return ThrowRedeclarationError(isolate, "const", name); 2217 return ThrowRedeclarationError(isolate, "const", name);
2218 } 2218 }
2219 } 2219 }
2220 if (object->IsJSGlobalObject()) { 2220 if (object->IsJSGlobalObject()) {
2221 // Define own property on the global object. 2221 // Define own property on the global object.
2222 RETURN_IF_EMPTY_HANDLE(isolate, 2222 RETURN_IF_EMPTY_HANDLE(isolate,
2223 JSObject::SetLocalPropertyIgnoreAttributes(object, name, value, mode)); 2223 JSObject::SetLocalPropertyIgnoreAttributes(object, name, value, mode));
2224 } else { 2224 } else {
2225 RETURN_IF_EMPTY_HANDLE(isolate, 2225 RETURN_IF_EMPTY_HANDLE(isolate,
2226 JSReceiver::SetProperty(object, name, value, mode, kNonStrictMode)); 2226 JSReceiver::SetProperty(object, name, value, mode, kSloppyMode));
2227 } 2227 }
2228 } 2228 }
2229 2229
2230 return isolate->heap()->undefined_value(); 2230 return isolate->heap()->undefined_value();
2231 } 2231 }
2232 2232
2233 2233
2234 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { 2234 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) {
2235 HandleScope scope(isolate); 2235 HandleScope scope(isolate);
2236 // args[0] == name 2236 // args[0] == name
2237 // args[1] == language_mode 2237 // args[1] == language_mode
2238 // args[2] == value (optional) 2238 // args[2] == value (optional)
2239 2239
2240 // Determine if we need to assign to the variable if it already 2240 // Determine if we need to assign to the variable if it already
2241 // exists (based on the number of arguments). 2241 // exists (based on the number of arguments).
2242 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); 2242 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3);
2243 bool assign = args.length() == 3; 2243 bool assign = args.length() == 3;
2244 2244
2245 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 2245 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
2246 RUNTIME_ASSERT(args[1]->IsSmi()); 2246 RUNTIME_ASSERT(args[1]->IsSmi());
2247 CONVERT_LANGUAGE_MODE_ARG(language_mode, 1); 2247 CONVERT_LANGUAGE_MODE_ARG(language_mode, 1);
2248 StrictModeFlag strict_mode_flag = (language_mode == CLASSIC_MODE) 2248 StrictModeFlag strict_mode_flag = (language_mode == SLOPPY_MODE)
2249 ? kNonStrictMode : kStrictMode; 2249 ? kSloppyMode : kStrictMode;
2250 2250
2251 // According to ECMA-262, section 12.2, page 62, the property must 2251 // According to ECMA-262, section 12.2, page 62, the property must
2252 // not be deletable. 2252 // not be deletable.
2253 PropertyAttributes attributes = DONT_DELETE; 2253 PropertyAttributes attributes = DONT_DELETE;
2254 2254
2255 // Lookup the property locally in the global object. If it isn't 2255 // Lookup the property locally in the global object. If it isn't
2256 // there, there is a property with this name in the prototype chain. 2256 // there, there is a property with this name in the prototype chain.
2257 // We follow Safari and Firefox behavior and only set the property 2257 // We follow Safari and Firefox behavior and only set the property
2258 // locally if there is an explicit initialization value that we have 2258 // locally if there is an explicit initialization value that we have
2259 // to assign to the property. 2259 // to assign to the property.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2327 2327
2328 if (!lookup.IsReadOnly()) { 2328 if (!lookup.IsReadOnly()) {
2329 // Restore global object from context (in case of GC) and continue 2329 // Restore global object from context (in case of GC) and continue
2330 // with setting the value. 2330 // with setting the value.
2331 HandleScope handle_scope(isolate); 2331 HandleScope handle_scope(isolate);
2332 Handle<GlobalObject> global(isolate->context()->global_object()); 2332 Handle<GlobalObject> global(isolate->context()->global_object());
2333 2333
2334 // BUG 1213575: Handle the case where we have to set a read-only 2334 // BUG 1213575: Handle the case where we have to set a read-only
2335 // property through an interceptor and only do it if it's 2335 // property through an interceptor and only do it if it's
2336 // uninitialized, e.g. the hole. Nirk... 2336 // uninitialized, e.g. the hole. Nirk...
2337 // Passing non-strict mode because the property is writable. 2337 // Passing sloppy mode because the property is writable.
2338 RETURN_IF_EMPTY_HANDLE( 2338 RETURN_IF_EMPTY_HANDLE(
2339 isolate, 2339 isolate,
2340 JSReceiver::SetProperty(global, name, value, attributes, 2340 JSReceiver::SetProperty(global, name, value, attributes, kSloppyMode));
2341 kNonStrictMode));
2342 return *value; 2341 return *value;
2343 } 2342 }
2344 2343
2345 // Set the value, but only if we're assigning the initial value to a 2344 // Set the value, but only if we're assigning the initial value to a
2346 // constant. For now, we determine this by checking if the 2345 // constant. For now, we determine this by checking if the
2347 // current value is the hole. 2346 // current value is the hole.
2348 // Strict mode handling not needed (const is disallowed in strict mode). 2347 // Strict mode handling not needed (const is disallowed in strict mode).
2349 if (lookup.IsField()) { 2348 if (lookup.IsField()) {
2350 FixedArray* properties = global->properties(); 2349 FixedArray* properties = global->properties();
2351 int index = lookup.GetFieldIndex().field_index(); 2350 int index = lookup.GetFieldIndex().field_index();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 } 2400 }
2402 2401
2403 // The property could not be found, we introduce it as a property of the 2402 // The property could not be found, we introduce it as a property of the
2404 // global object. 2403 // global object.
2405 if (attributes == ABSENT) { 2404 if (attributes == ABSENT) {
2406 Handle<JSObject> global = Handle<JSObject>( 2405 Handle<JSObject> global = Handle<JSObject>(
2407 isolate->context()->global_object()); 2406 isolate->context()->global_object());
2408 // Strict mode not needed (const disallowed in strict mode). 2407 // Strict mode not needed (const disallowed in strict mode).
2409 RETURN_IF_EMPTY_HANDLE( 2408 RETURN_IF_EMPTY_HANDLE(
2410 isolate, 2409 isolate,
2411 JSReceiver::SetProperty(global, name, value, NONE, kNonStrictMode)); 2410 JSReceiver::SetProperty(global, name, value, NONE, kSloppyMode));
2412 return *value; 2411 return *value;
2413 } 2412 }
2414 2413
2415 // The property was present in some function's context extension object, 2414 // The property was present in some function's context extension object,
2416 // as a property on the subject of a with, or as a property of the global 2415 // as a property on the subject of a with, or as a property of the global
2417 // object. 2416 // object.
2418 // 2417 //
2419 // In most situations, eval-introduced consts should still be present in 2418 // In most situations, eval-introduced consts should still be present in
2420 // the context extension object. However, because declaration and 2419 // the context extension object. However, because declaration and
2421 // initialization are separate, the property might have been deleted 2420 // initialization are separate, the property might have been deleted
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2453 UNREACHABLE(); 2452 UNREACHABLE();
2454 } 2453 }
2455 } else { 2454 } else {
2456 // The property was found on some other object. Set it if it is not a 2455 // The property was found on some other object. Set it if it is not a
2457 // read-only property. 2456 // read-only property.
2458 if ((attributes & READ_ONLY) == 0) { 2457 if ((attributes & READ_ONLY) == 0) {
2459 // Strict mode not needed (const disallowed in strict mode). 2458 // Strict mode not needed (const disallowed in strict mode).
2460 RETURN_IF_EMPTY_HANDLE( 2459 RETURN_IF_EMPTY_HANDLE(
2461 isolate, 2460 isolate,
2462 JSReceiver::SetProperty(object, name, value, attributes, 2461 JSReceiver::SetProperty(object, name, value, attributes,
2463 kNonStrictMode)); 2462 kSloppyMode));
2464 } 2463 }
2465 } 2464 }
2466 2465
2467 return *value; 2466 return *value;
2468 } 2467 }
2469 2468
2470 2469
2471 RUNTIME_FUNCTION(MaybeObject*, 2470 RUNTIME_FUNCTION(MaybeObject*,
2472 Runtime_OptimizeObjectForAddingMultipleProperties) { 2471 Runtime_OptimizeObjectForAddingMultipleProperties) {
2473 HandleScope scope(isolate); 2472 HandleScope scope(isolate);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); 2635 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift);
2637 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); 2636 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift);
2638 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); 2637 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice);
2639 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); 2638 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice);
2640 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); 2639 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat);
2641 2640
2642 return *holder; 2641 return *holder;
2643 } 2642 }
2644 2643
2645 2644
2646 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsClassicModeFunction) { 2645 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsSloppyModeFunction) {
2647 SealHandleScope shs(isolate); 2646 SealHandleScope shs(isolate);
2648 ASSERT(args.length() == 1); 2647 ASSERT(args.length() == 1);
2649 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 2648 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
2650 if (!callable->IsJSFunction()) { 2649 if (!callable->IsJSFunction()) {
2651 HandleScope scope(isolate); 2650 HandleScope scope(isolate);
2652 bool threw = false; 2651 bool threw = false;
2653 Handle<Object> delegate = Execution::TryGetFunctionDelegate( 2652 Handle<Object> delegate = Execution::TryGetFunctionDelegate(
2654 isolate, Handle<JSReceiver>(callable), &threw); 2653 isolate, Handle<JSReceiver>(callable), &threw);
2655 if (threw) return Failure::Exception(); 2654 if (threw) return Failure::Exception();
2656 callable = JSFunction::cast(*delegate); 2655 callable = JSFunction::cast(*delegate);
2657 } 2656 }
2658 JSFunction* function = JSFunction::cast(callable); 2657 JSFunction* function = JSFunction::cast(callable);
2659 SharedFunctionInfo* shared = function->shared(); 2658 SharedFunctionInfo* shared = function->shared();
2660 return isolate->heap()->ToBoolean(shared->is_classic_mode()); 2659 return isolate->heap()->ToBoolean(shared->is_sloppy_mode());
2661 } 2660 }
2662 2661
2663 2662
2664 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { 2663 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) {
2665 SealHandleScope shs(isolate); 2664 SealHandleScope shs(isolate);
2666 ASSERT(args.length() == 1); 2665 ASSERT(args.length() == 1);
2667 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); 2666 CONVERT_ARG_CHECKED(JSReceiver, callable, 0);
2668 2667
2669 if (!callable->IsJSFunction()) { 2668 if (!callable->IsJSFunction()) {
2670 HandleScope scope(isolate); 2669 HandleScope scope(isolate);
2671 bool threw = false; 2670 bool threw = false;
2672 Handle<Object> delegate = Execution::TryGetFunctionDelegate( 2671 Handle<Object> delegate = Execution::TryGetFunctionDelegate(
2673 isolate, Handle<JSReceiver>(callable), &threw); 2672 isolate, Handle<JSReceiver>(callable), &threw);
2674 if (threw) return Failure::Exception(); 2673 if (threw) return Failure::Exception();
2675 callable = JSFunction::cast(*delegate); 2674 callable = JSFunction::cast(*delegate);
2676 } 2675 }
2677 JSFunction* function = JSFunction::cast(callable); 2676 JSFunction* function = JSFunction::cast(callable);
2678 2677
2679 SharedFunctionInfo* shared = function->shared(); 2678 SharedFunctionInfo* shared = function->shared();
2680 if (shared->native() || !shared->is_classic_mode()) { 2679 if (shared->native() || !shared->is_sloppy_mode()) {
2681 return isolate->heap()->undefined_value(); 2680 return isolate->heap()->undefined_value();
2682 } 2681 }
2683 // Returns undefined for strict or native functions, or 2682 // Returns undefined for strict or native functions, or
2684 // the associated global receiver for "normal" functions. 2683 // the associated global receiver for "normal" functions.
2685 2684
2686 Context* native_context = 2685 Context* native_context =
2687 function->context()->global_object()->native_context(); 2686 function->context()->global_object()->native_context();
2688 return native_context->global_object()->global_receiver(); 2687 return native_context->global_object()->global_receiver();
2689 } 2688 }
2690 2689
(...skipping 2575 matching lines...) Expand 10 before | Expand all | Expand 10 after
5266 // of a string using [] notation. We need to support this too in 5265 // of a string using [] notation. We need to support this too in
5267 // JavaScript. 5266 // JavaScript.
5268 // In the case of a String object we just need to redirect the assignment to 5267 // In the case of a String object we just need to redirect the assignment to
5269 // the underlying string if the index is in range. Since the underlying 5268 // the underlying string if the index is in range. Since the underlying
5270 // string does nothing with the assignment then we can ignore such 5269 // string does nothing with the assignment then we can ignore such
5271 // assignments. 5270 // assignments.
5272 if (js_object->IsStringObjectWithCharacterAt(index)) { 5271 if (js_object->IsStringObjectWithCharacterAt(index)) {
5273 return value; 5272 return value;
5274 } 5273 }
5275 5274
5276 return JSObject::SetElement(js_object, index, value, attr, kNonStrictMode, 5275 return JSObject::SetElement(js_object, index, value, attr, kSloppyMode,
5277 false, 5276 false,
5278 DEFINE_PROPERTY); 5277 DEFINE_PROPERTY);
5279 } 5278 }
5280 5279
5281 if (key->IsName()) { 5280 if (key->IsName()) {
5282 Handle<Name> name = Handle<Name>::cast(key); 5281 Handle<Name> name = Handle<Name>::cast(key);
5283 if (name->AsArrayIndex(&index)) { 5282 if (name->AsArrayIndex(&index)) {
5284 return JSObject::SetElement(js_object, index, value, attr, kNonStrictMode, 5283 return JSObject::SetElement(js_object, index, value, attr, kSloppyMode,
5285 false, 5284 false,
5286 DEFINE_PROPERTY); 5285 DEFINE_PROPERTY);
5287 } else { 5286 } else {
5288 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); 5287 if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
5289 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, 5288 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name,
5290 value, attr); 5289 value, attr);
5291 } 5290 }
5292 } 5291 }
5293 5292
5294 // Call-back into JavaScript to convert the key to a string. 5293 // Call-back into JavaScript to convert the key to a string.
5295 bool has_pending_exception = false; 5294 bool has_pending_exception = false;
5296 Handle<Object> converted = 5295 Handle<Object> converted =
5297 Execution::ToString(isolate, key, &has_pending_exception); 5296 Execution::ToString(isolate, key, &has_pending_exception);
5298 if (has_pending_exception) return Handle<Object>(); // exception 5297 if (has_pending_exception) return Handle<Object>(); // exception
5299 Handle<String> name = Handle<String>::cast(converted); 5298 Handle<String> name = Handle<String>::cast(converted);
5300 5299
5301 if (name->AsArrayIndex(&index)) { 5300 if (name->AsArrayIndex(&index)) {
5302 return JSObject::SetElement(js_object, index, value, attr, kNonStrictMode, 5301 return JSObject::SetElement(js_object, index, value, attr, kSloppyMode,
5303 false, 5302 false,
5304 DEFINE_PROPERTY); 5303 DEFINE_PROPERTY);
5305 } else { 5304 } else {
5306 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value, 5305 return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value,
5307 attr); 5306 attr);
5308 } 5307 }
5309 } 5308 }
5310 5309
5311 5310
5312 MaybeObject* Runtime::DeleteObjectProperty(Isolate* isolate, 5311 MaybeObject* Runtime::DeleteObjectProperty(Isolate* isolate,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5359 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); 5358 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
5360 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 5359 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
5361 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 5360 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
5362 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); 5361 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3);
5363 RUNTIME_ASSERT( 5362 RUNTIME_ASSERT(
5364 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); 5363 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
5365 // Compute attributes. 5364 // Compute attributes.
5366 PropertyAttributes attributes = 5365 PropertyAttributes attributes =
5367 static_cast<PropertyAttributes>(unchecked_attributes); 5366 static_cast<PropertyAttributes>(unchecked_attributes);
5368 5367
5369 StrictModeFlag strict_mode = kNonStrictMode; 5368 StrictModeFlag strict_mode = kSloppyMode;
5370 if (args.length() == 5) { 5369 if (args.length() == 5) {
5371 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_flag, 4); 5370 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_flag, 4);
5372 strict_mode = strict_mode_flag; 5371 strict_mode = strict_mode_flag;
5373 } 5372 }
5374 5373
5375 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key, 5374 Handle<Object> result = Runtime::SetObjectProperty(isolate, object, key,
5376 value, 5375 value,
5377 attributes, 5376 attributes,
5378 strict_mode); 5377 strict_mode);
5379 RETURN_IF_EMPTY_HANDLE(isolate, result); 5378 RETURN_IF_EMPTY_HANDLE(isolate, result);
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
5983 return frame->GetParameter(index); 5982 return frame->GetParameter(index);
5984 } else { 5983 } else {
5985 return isolate->initial_object_prototype()->GetElement(isolate, index); 5984 return isolate->initial_object_prototype()->GetElement(isolate, index);
5986 } 5985 }
5987 } 5986 }
5988 5987
5989 // Handle special arguments properties. 5988 // Handle special arguments properties.
5990 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n); 5989 if (key->Equals(isolate->heap()->length_string())) return Smi::FromInt(n);
5991 if (key->Equals(isolate->heap()->callee_string())) { 5990 if (key->Equals(isolate->heap()->callee_string())) {
5992 JSFunction* function = frame->function(); 5991 JSFunction* function = frame->function();
5993 if (!function->shared()->is_classic_mode()) { 5992 if (!function->shared()->is_sloppy_mode()) {
5994 return isolate->Throw(*isolate->factory()->NewTypeError( 5993 return isolate->Throw(*isolate->factory()->NewTypeError(
5995 "strict_arguments_callee", HandleVector<Object>(NULL, 0))); 5994 "strict_arguments_callee", HandleVector<Object>(NULL, 0)));
5996 } 5995 }
5997 return function; 5996 return function;
5998 } 5997 }
5999 5998
6000 // Lookup in the initial Object.prototype object. 5999 // Lookup in the initial Object.prototype object.
6001 return isolate->initial_object_prototype()->GetProperty(*key); 6000 return isolate->initial_object_prototype()->GetProperty(*key);
6002 } 6001 }
6003 6002
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after
7968 Handle<JSObject> result = 7967 Handle<JSObject> result =
7969 isolate->factory()->NewArgumentsObject(callee, argument_count); 7968 isolate->factory()->NewArgumentsObject(callee, argument_count);
7970 // Allocate the elements if needed. 7969 // Allocate the elements if needed.
7971 int parameter_count = callee->shared()->formal_parameter_count(); 7970 int parameter_count = callee->shared()->formal_parameter_count();
7972 if (argument_count > 0) { 7971 if (argument_count > 0) {
7973 if (parameter_count > 0) { 7972 if (parameter_count > 0) {
7974 int mapped_count = Min(argument_count, parameter_count); 7973 int mapped_count = Min(argument_count, parameter_count);
7975 Handle<FixedArray> parameter_map = 7974 Handle<FixedArray> parameter_map =
7976 isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED); 7975 isolate->factory()->NewFixedArray(mapped_count + 2, NOT_TENURED);
7977 parameter_map->set_map( 7976 parameter_map->set_map(
7978 isolate->heap()->non_strict_arguments_elements_map()); 7977 isolate->heap()->sloppy_arguments_elements_map());
7979 7978
7980 Handle<Map> old_map(result->map()); 7979 Handle<Map> old_map(result->map());
7981 Handle<Map> new_map = isolate->factory()->CopyMap(old_map); 7980 Handle<Map> new_map = isolate->factory()->CopyMap(old_map);
7982 new_map->set_elements_kind(NON_STRICT_ARGUMENTS_ELEMENTS); 7981 new_map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS);
7983 7982
7984 result->set_map(*new_map); 7983 result->set_map(*new_map);
7985 result->set_elements(*parameter_map); 7984 result->set_elements(*parameter_map);
7986 7985
7987 // Store the context and the arguments array at the beginning of the 7986 // Store the context and the arguments array at the beginning of the
7988 // parameter map. 7987 // parameter map.
7989 Handle<Context> context(isolate->context()); 7988 Handle<Context> context(isolate->context());
7990 Handle<FixedArray> arguments = 7989 Handle<FixedArray> arguments =
7991 isolate->factory()->NewFixedArray(argument_count, NOT_TENURED); 7990 isolate->factory()->NewFixedArray(argument_count, NOT_TENURED);
7992 parameter_map->set(0, *context); 7991 parameter_map->set(0, *context);
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after
9341 9340
9342 9341
9343 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) { 9342 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreContextSlot) {
9344 HandleScope scope(isolate); 9343 HandleScope scope(isolate);
9345 ASSERT(args.length() == 4); 9344 ASSERT(args.length() == 4);
9346 9345
9347 Handle<Object> value(args[0], isolate); 9346 Handle<Object> value(args[0], isolate);
9348 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); 9347 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1);
9349 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); 9348 CONVERT_ARG_HANDLE_CHECKED(String, name, 2);
9350 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3); 9349 CONVERT_LANGUAGE_MODE_ARG(language_mode, 3);
9351 StrictModeFlag strict_mode = (language_mode == CLASSIC_MODE) 9350 StrictModeFlag strict_mode = (language_mode == SLOPPY_MODE)
9352 ? kNonStrictMode : kStrictMode; 9351 ? kSloppyMode : kStrictMode;
9353 9352
9354 int index; 9353 int index;
9355 PropertyAttributes attributes; 9354 PropertyAttributes attributes;
9356 ContextLookupFlags flags = FOLLOW_CHAINS; 9355 ContextLookupFlags flags = FOLLOW_CHAINS;
9357 BindingFlags binding_flags; 9356 BindingFlags binding_flags;
9358 Handle<Object> holder = context->Lookup(name, 9357 Handle<Object> holder = context->Lookup(name,
9359 flags, 9358 flags,
9360 &index, 9359 &index,
9361 &attributes, 9360 &attributes,
9362 &binding_flags); 9361 &binding_flags);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
9398 // The property was not found. 9397 // The property was not found.
9399 ASSERT(attributes == ABSENT); 9398 ASSERT(attributes == ABSENT);
9400 9399
9401 if (strict_mode == kStrictMode) { 9400 if (strict_mode == kStrictMode) {
9402 // Throw in strict mode (assignment to undefined variable). 9401 // Throw in strict mode (assignment to undefined variable).
9403 Handle<Object> error = 9402 Handle<Object> error =
9404 isolate->factory()->NewReferenceError( 9403 isolate->factory()->NewReferenceError(
9405 "not_defined", HandleVector(&name, 1)); 9404 "not_defined", HandleVector(&name, 1));
9406 return isolate->Throw(*error); 9405 return isolate->Throw(*error);
9407 } 9406 }
9408 // In non-strict mode, the property is added to the global object. 9407 // In sloppy mode, the property is added to the global object.
9409 attributes = NONE; 9408 attributes = NONE;
9410 object = Handle<JSReceiver>(isolate->context()->global_object()); 9409 object = Handle<JSReceiver>(isolate->context()->global_object());
9411 } 9410 }
9412 9411
9413 // Set the property if it's not read only or doesn't yet exist. 9412 // Set the property if it's not read only or doesn't yet exist.
9414 if ((attributes & READ_ONLY) == 0 || 9413 if ((attributes & READ_ONLY) == 0 ||
9415 (object->GetLocalPropertyAttribute(*name) == ABSENT)) { 9414 (object->GetLocalPropertyAttribute(*name) == ABSENT)) {
9416 RETURN_IF_EMPTY_HANDLE( 9415 RETURN_IF_EMPTY_HANDLE(
9417 isolate, 9416 isolate,
9418 JSReceiver::SetProperty(object, name, value, NONE, strict_mode)); 9417 JSReceiver::SetProperty(object, name, value, NONE, strict_mode));
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
9748 Handle<Object> error_message = 9747 Handle<Object> error_message =
9749 context->ErrorMessageForCodeGenerationFromStrings(); 9748 context->ErrorMessageForCodeGenerationFromStrings();
9750 return isolate->Throw(*isolate->factory()->NewEvalError( 9749 return isolate->Throw(*isolate->factory()->NewEvalError(
9751 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); 9750 "code_gen_from_strings", HandleVector<Object>(&error_message, 1)));
9752 } 9751 }
9753 9752
9754 // Compile source string in the native context. 9753 // Compile source string in the native context.
9755 ParseRestriction restriction = function_literal_only 9754 ParseRestriction restriction = function_literal_only
9756 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION; 9755 ? ONLY_SINGLE_FUNCTION_LITERAL : NO_PARSE_RESTRICTION;
9757 Handle<JSFunction> fun = Compiler::GetFunctionFromEval( 9756 Handle<JSFunction> fun = Compiler::GetFunctionFromEval(
9758 source, context, CLASSIC_MODE, restriction, RelocInfo::kNoPosition); 9757 source, context, SLOPPY_MODE, restriction, RelocInfo::kNoPosition);
9759 RETURN_IF_EMPTY_HANDLE(isolate, fun); 9758 RETURN_IF_EMPTY_HANDLE(isolate, fun);
9760 return *fun; 9759 return *fun;
9761 } 9760 }
9762 9761
9763 9762
9764 static ObjectPair CompileGlobalEval(Isolate* isolate, 9763 static ObjectPair CompileGlobalEval(Isolate* isolate,
9765 Handle<String> source, 9764 Handle<String> source,
9766 Handle<Object> receiver, 9765 Handle<Object> receiver,
9767 LanguageMode language_mode, 9766 LanguageMode language_mode,
9768 int scope_position) { 9767 int scope_position) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
9870 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); 9869 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements());
9871 int length = Smi::cast(array->length())->value(); 9870 int length = Smi::cast(array->length())->value();
9872 FixedArray* elements = FixedArray::cast(array->elements()); 9871 FixedArray* elements = FixedArray::cast(array->elements());
9873 for (int i = 0; i < length; i++) { 9872 for (int i = 0; i < length; i++) {
9874 if (elements->get(i) == *element) return isolate->heap()->false_value(); 9873 if (elements->get(i) == *element) return isolate->heap()->false_value();
9875 } 9874 }
9876 9875
9877 // Strict not needed. Used for cycle detection in Array join implementation. 9876 // Strict not needed. Used for cycle detection in Array join implementation.
9878 RETURN_IF_EMPTY_HANDLE(isolate, JSObject::SetFastElement(array, length, 9877 RETURN_IF_EMPTY_HANDLE(isolate, JSObject::SetFastElement(array, length,
9879 element, 9878 element,
9880 kNonStrictMode, 9879 kSloppyMode,
9881 true)); 9880 true));
9882 return isolate->heap()->true_value(); 9881 return isolate->heap()->true_value();
9883 } 9882 }
9884 9883
9885 9884
9886 /** 9885 /**
9887 * A simple visitor visits every element of Array's. 9886 * A simple visitor visits every element of Array's.
9888 * The backend storage can be a fixed array for fast elements case, 9887 * The backend storage can be a fixed array for fast elements case,
9889 * or a dictionary for sparse array. Since Dictionary is a subtype 9888 * or a dictionary for sparse array. Since Dictionary is a subtype
9890 * of FixedArray, the class can be used by both fast and slow cases. 9889 * of FixedArray, the class can be used by both fast and slow cases.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
10055 SeededNumberDictionary::cast(array->elements())); 10054 SeededNumberDictionary::cast(array->elements()));
10056 int capacity = dictionary->Capacity(); 10055 int capacity = dictionary->Capacity();
10057 for (int i = 0; i < capacity; i++) { 10056 for (int i = 0; i < capacity; i++) {
10058 Handle<Object> key(dictionary->KeyAt(i), array->GetIsolate()); 10057 Handle<Object> key(dictionary->KeyAt(i), array->GetIsolate());
10059 if (dictionary->IsKey(*key)) { 10058 if (dictionary->IsKey(*key)) {
10060 element_count++; 10059 element_count++;
10061 } 10060 }
10062 } 10061 }
10063 break; 10062 break;
10064 } 10063 }
10065 case NON_STRICT_ARGUMENTS_ELEMENTS: 10064 case SLOPPY_ARGUMENTS_ELEMENTS:
10066 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 10065 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
10067 case EXTERNAL_##TYPE##_ELEMENTS: \ 10066 case EXTERNAL_##TYPE##_ELEMENTS: \
10068 case TYPE##_ELEMENTS: \ 10067 case TYPE##_ELEMENTS: \
10069 10068
10070 TYPED_ARRAYS(TYPED_ARRAY_CASE) 10069 TYPED_ARRAYS(TYPED_ARRAY_CASE)
10071 #undef TYPED_ARRAY_CASE 10070 #undef TYPED_ARRAY_CASE
10072 // External arrays are always dense. 10071 // External arrays are always dense.
10073 return length; 10072 return length;
10074 } 10073 }
10075 // As an estimate, we assume that the prototype doesn't contain any 10074 // As an estimate, we assume that the prototype doesn't contain any
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
11342 // Add the value being returned. 11341 // Add the value being returned.
11343 if (at_return) { 11342 if (at_return) {
11344 details->set(details_index++, *return_value); 11343 details->set(details_index++, *return_value);
11345 } 11344 }
11346 11345
11347 // Add the receiver (same as in function frame). 11346 // Add the receiver (same as in function frame).
11348 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE 11347 // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE
11349 // THE FRAME ITERATOR TO WRAP THE RECEIVER. 11348 // THE FRAME ITERATOR TO WRAP THE RECEIVER.
11350 Handle<Object> receiver(it.frame()->receiver(), isolate); 11349 Handle<Object> receiver(it.frame()->receiver(), isolate);
11351 if (!receiver->IsJSObject() && 11350 if (!receiver->IsJSObject() &&
11352 shared->is_classic_mode() && 11351 shared->is_sloppy_mode() &&
11353 !function->IsBuiltin()) { 11352 !function->IsBuiltin()) {
11354 // If the receiver is not a JSObject and the function is not a 11353 // If the receiver is not a JSObject and the function is not a
11355 // builtin or strict-mode we have hit an optimization where a 11354 // builtin or strict-mode we have hit an optimization where a
11356 // value object is not converted into a wrapped JS objects. To 11355 // value object is not converted into a wrapped JS objects. To
11357 // hide this optimization from the debugger, we wrap the receiver 11356 // hide this optimization from the debugger, we wrap the receiver
11358 // by creating correct wrapper object based on the calling frame's 11357 // by creating correct wrapper object based on the calling frame's
11359 // native context. 11358 // native context.
11360 it.Advance(); 11359 it.Advance();
11361 if (receiver->IsUndefined()) { 11360 if (receiver->IsUndefined()) {
11362 Context* context = function->context(); 11361 Context* context = function->context();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
11395 11394
11396 Handle<Object> value(i < frame_inspector->GetParametersCount() 11395 Handle<Object> value(i < frame_inspector->GetParametersCount()
11397 ? frame_inspector->GetParameter(i) 11396 ? frame_inspector->GetParameter(i)
11398 : isolate->heap()->undefined_value(), 11397 : isolate->heap()->undefined_value(),
11399 isolate); 11398 isolate);
11400 ASSERT(!value->IsTheHole()); 11399 ASSERT(!value->IsTheHole());
11401 11400
11402 RETURN_IF_EMPTY_HANDLE_VALUE( 11401 RETURN_IF_EMPTY_HANDLE_VALUE(
11403 isolate, 11402 isolate,
11404 Runtime::SetObjectProperty( 11403 Runtime::SetObjectProperty(
11405 isolate, target, name, value, NONE, kNonStrictMode), 11404 isolate, target, name, value, NONE, kSloppyMode),
11406 Handle<JSObject>()); 11405 Handle<JSObject>());
11407 } 11406 }
11408 11407
11409 // Second fill all stack locals. 11408 // Second fill all stack locals.
11410 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { 11409 for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
11411 Handle<String> name(scope_info->StackLocalName(i)); 11410 Handle<String> name(scope_info->StackLocalName(i));
11412 Handle<Object> value(frame_inspector->GetExpression(i), isolate); 11411 Handle<Object> value(frame_inspector->GetExpression(i), isolate);
11413 if (value->IsTheHole()) continue; 11412 if (value->IsTheHole()) continue;
11414 11413
11415 RETURN_IF_EMPTY_HANDLE_VALUE( 11414 RETURN_IF_EMPTY_HANDLE_VALUE(
11416 isolate, 11415 isolate,
11417 Runtime::SetObjectProperty( 11416 Runtime::SetObjectProperty(
11418 isolate, target, name, value, NONE, kNonStrictMode), 11417 isolate, target, name, value, NONE, kSloppyMode),
11419 Handle<JSObject>()); 11418 Handle<JSObject>());
11420 } 11419 }
11421 11420
11422 return target; 11421 return target;
11423 } 11422 }
11424 11423
11425 11424
11426 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate, 11425 static void UpdateStackLocalsFromMaterializedObject(Isolate* isolate,
11427 Handle<JSObject> target, 11426 Handle<JSObject> target,
11428 Handle<JSFunction> function, 11427 Handle<JSFunction> function,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
11491 // Names of variables introduced by eval are strings. 11490 // Names of variables introduced by eval are strings.
11492 ASSERT(keys->get(i)->IsString()); 11491 ASSERT(keys->get(i)->IsString());
11493 Handle<String> key(String::cast(keys->get(i))); 11492 Handle<String> key(String::cast(keys->get(i)));
11494 RETURN_IF_EMPTY_HANDLE_VALUE( 11493 RETURN_IF_EMPTY_HANDLE_VALUE(
11495 isolate, 11494 isolate,
11496 Runtime::SetObjectProperty(isolate, 11495 Runtime::SetObjectProperty(isolate,
11497 target, 11496 target,
11498 key, 11497 key,
11499 GetProperty(isolate, ext, key), 11498 GetProperty(isolate, ext, key),
11500 NONE, 11499 NONE,
11501 kNonStrictMode), 11500 kSloppyMode),
11502 Handle<JSObject>()); 11501 Handle<JSObject>());
11503 } 11502 }
11504 } 11503 }
11505 } 11504 }
11506 11505
11507 return target; 11506 return target;
11508 } 11507 }
11509 11508
11510 11509
11511 static Handle<JSObject> MaterializeLocalScope( 11510 static Handle<JSObject> MaterializeLocalScope(
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
11593 if (function_context->closure() == *function) { 11592 if (function_context->closure() == *function) {
11594 if (function_context->has_extension() && 11593 if (function_context->has_extension() &&
11595 !function_context->IsNativeContext()) { 11594 !function_context->IsNativeContext()) {
11596 Handle<JSObject> ext(JSObject::cast(function_context->extension())); 11595 Handle<JSObject> ext(JSObject::cast(function_context->extension()));
11597 11596
11598 if (JSReceiver::HasProperty(ext, variable_name)) { 11597 if (JSReceiver::HasProperty(ext, variable_name)) {
11599 // We don't expect this to do anything except replacing 11598 // We don't expect this to do anything except replacing
11600 // property value. 11599 // property value.
11601 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, 11600 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
11602 NONE, 11601 NONE,
11603 kNonStrictMode); 11602 kSloppyMode);
11604 return true; 11603 return true;
11605 } 11604 }
11606 } 11605 }
11607 } 11606 }
11608 } 11607 }
11609 11608
11610 return default_result; 11609 return default_result;
11611 } 11610 }
11612 11611
11613 11612
(...skipping 28 matching lines...) Expand all
11642 11641
11643 for (int i = 0; i < keys->length(); i++) { 11642 for (int i = 0; i < keys->length(); i++) {
11644 // Names of variables introduced by eval are strings. 11643 // Names of variables introduced by eval are strings.
11645 ASSERT(keys->get(i)->IsString()); 11644 ASSERT(keys->get(i)->IsString());
11646 Handle<String> key(String::cast(keys->get(i))); 11645 Handle<String> key(String::cast(keys->get(i)));
11647 RETURN_IF_EMPTY_HANDLE_VALUE( 11646 RETURN_IF_EMPTY_HANDLE_VALUE(
11648 isolate, 11647 isolate,
11649 Runtime::SetObjectProperty(isolate, closure_scope, key, 11648 Runtime::SetObjectProperty(isolate, closure_scope, key,
11650 GetProperty(isolate, ext, key), 11649 GetProperty(isolate, ext, key),
11651 NONE, 11650 NONE,
11652 kNonStrictMode), 11651 kSloppyMode),
11653 Handle<JSObject>()); 11652 Handle<JSObject>());
11654 } 11653 }
11655 } 11654 }
11656 11655
11657 return closure_scope; 11656 return closure_scope;
11658 } 11657 }
11659 11658
11660 11659
11661 // This method copies structure of MaterializeClosure method above. 11660 // This method copies structure of MaterializeClosure method above.
11662 static bool SetClosureVariableValue(Isolate* isolate, 11661 static bool SetClosureVariableValue(Isolate* isolate,
(...skipping 12 matching lines...) Expand all
11675 } 11674 }
11676 11675
11677 // Properties from the function context extension. This will 11676 // Properties from the function context extension. This will
11678 // be variables introduced by eval. 11677 // be variables introduced by eval.
11679 if (context->has_extension()) { 11678 if (context->has_extension()) {
11680 Handle<JSObject> ext(JSObject::cast(context->extension())); 11679 Handle<JSObject> ext(JSObject::cast(context->extension()));
11681 if (JSReceiver::HasProperty(ext, variable_name)) { 11680 if (JSReceiver::HasProperty(ext, variable_name)) {
11682 // We don't expect this to do anything except replacing property value. 11681 // We don't expect this to do anything except replacing property value.
11683 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value, 11682 Runtime::SetObjectProperty(isolate, ext, variable_name, new_value,
11684 NONE, 11683 NONE,
11685 kNonStrictMode); 11684 kSloppyMode);
11686 return true; 11685 return true;
11687 } 11686 }
11688 } 11687 }
11689 11688
11690 return false; 11689 return false;
11691 } 11690 }
11692 11691
11693 11692
11694 // Create a plain JSObject which materializes the scope for the specified 11693 // Create a plain JSObject which materializes the scope for the specified
11695 // catch context. 11694 // catch context.
11696 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate, 11695 static Handle<JSObject> MaterializeCatchScope(Isolate* isolate,
11697 Handle<Context> context) { 11696 Handle<Context> context) {
11698 ASSERT(context->IsCatchContext()); 11697 ASSERT(context->IsCatchContext());
11699 Handle<String> name(String::cast(context->extension())); 11698 Handle<String> name(String::cast(context->extension()));
11700 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX), 11699 Handle<Object> thrown_object(context->get(Context::THROWN_OBJECT_INDEX),
11701 isolate); 11700 isolate);
11702 Handle<JSObject> catch_scope = 11701 Handle<JSObject> catch_scope =
11703 isolate->factory()->NewJSObject(isolate->object_function()); 11702 isolate->factory()->NewJSObject(isolate->object_function());
11704 RETURN_IF_EMPTY_HANDLE_VALUE( 11703 RETURN_IF_EMPTY_HANDLE_VALUE(
11705 isolate, 11704 isolate,
11706 Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object, 11705 Runtime::SetObjectProperty(isolate, catch_scope, name, thrown_object,
11707 NONE, 11706 NONE,
11708 kNonStrictMode), 11707 kSloppyMode),
11709 Handle<JSObject>()); 11708 Handle<JSObject>());
11710 return catch_scope; 11709 return catch_scope;
11711 } 11710 }
11712 11711
11713 11712
11714 static bool SetCatchVariableValue(Isolate* isolate, 11713 static bool SetCatchVariableValue(Isolate* isolate,
11715 Handle<Context> context, 11714 Handle<Context> context,
11716 Handle<String> variable_name, 11715 Handle<String> variable_name,
11717 Handle<Object> new_value) { 11716 Handle<Object> new_value) {
11718 ASSERT(context->IsCatchContext()); 11717 ASSERT(context->IsCatchContext());
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
12211 // If our frame is a top frame and we are stepping, we can do step-in 12210 // If our frame is a top frame and we are stepping, we can do step-in
12212 // at this place. 12211 // at this place.
12213 accept = additional_frame_it.frame()->id() == id; 12212 accept = additional_frame_it.frame()->id() == id;
12214 } 12213 }
12215 } 12214 }
12216 if (accept) { 12215 if (accept) {
12217 if (break_location_iterator.IsStepInLocation(isolate)) { 12216 if (break_location_iterator.IsStepInLocation(isolate)) {
12218 Smi* position_value = Smi::FromInt(break_location_iterator.position()); 12217 Smi* position_value = Smi::FromInt(break_location_iterator.position());
12219 JSObject::SetElement(array, len, 12218 JSObject::SetElement(array, len,
12220 Handle<Object>(position_value, isolate), 12219 Handle<Object>(position_value, isolate),
12221 NONE, kNonStrictMode); 12220 NONE, kSloppyMode);
12222 len++; 12221 len++;
12223 } 12222 }
12224 } 12223 }
12225 // Advance iterator. 12224 // Advance iterator.
12226 break_location_iterator.Next(); 12225 break_location_iterator.Next();
12227 if (current_statement_pos != 12226 if (current_statement_pos !=
12228 break_location_iterator.statement_position()) { 12227 break_location_iterator.statement_position()) {
12229 break; 12228 break;
12230 } 12229 }
12231 } 12230 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
12720 return target; 12719 return target;
12721 } 12720 }
12722 12721
12723 // FunctionGetArguments can't throw an exception. 12722 // FunctionGetArguments can't throw an exception.
12724 Handle<JSObject> arguments = Handle<JSObject>::cast( 12723 Handle<JSObject> arguments = Handle<JSObject>::cast(
12725 Accessors::FunctionGetArguments(function)); 12724 Accessors::FunctionGetArguments(function));
12726 Runtime::SetObjectProperty(isolate, target, 12725 Runtime::SetObjectProperty(isolate, target,
12727 isolate->factory()->arguments_string(), 12726 isolate->factory()->arguments_string(),
12728 arguments, 12727 arguments,
12729 ::NONE, 12728 ::NONE,
12730 kNonStrictMode); 12729 kSloppyMode);
12731 return target; 12730 return target;
12732 } 12731 }
12733 12732
12734 12733
12735 // Compile and evaluate source for the given context. 12734 // Compile and evaluate source for the given context.
12736 static MaybeObject* DebugEvaluate(Isolate* isolate, 12735 static MaybeObject* DebugEvaluate(Isolate* isolate,
12737 Handle<Context> context, 12736 Handle<Context> context,
12738 Handle<Object> context_extension, 12737 Handle<Object> context_extension,
12739 Handle<Object> receiver, 12738 Handle<Object> receiver,
12740 Handle<String> source) { 12739 Handle<String> source) {
12741 if (context_extension->IsJSObject()) { 12740 if (context_extension->IsJSObject()) {
12742 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension); 12741 Handle<JSObject> extension = Handle<JSObject>::cast(context_extension);
12743 Handle<JSFunction> closure(context->closure(), isolate); 12742 Handle<JSFunction> closure(context->closure(), isolate);
12744 context = isolate->factory()->NewWithContext(closure, context, extension); 12743 context = isolate->factory()->NewWithContext(closure, context, extension);
12745 } 12744 }
12746 12745
12747 Handle<JSFunction> eval_fun = 12746 Handle<JSFunction> eval_fun =
12748 Compiler::GetFunctionFromEval(source, 12747 Compiler::GetFunctionFromEval(source,
12749 context, 12748 context,
12750 CLASSIC_MODE, 12749 SLOPPY_MODE,
12751 NO_PARSE_RESTRICTION, 12750 NO_PARSE_RESTRICTION,
12752 RelocInfo::kNoPosition); 12751 RelocInfo::kNoPosition);
12753 RETURN_IF_EMPTY_HANDLE(isolate, eval_fun); 12752 RETURN_IF_EMPTY_HANDLE(isolate, eval_fun);
12754 12753
12755 bool pending_exception; 12754 bool pending_exception;
12756 Handle<Object> result = Execution::Call( 12755 Handle<Object> result = Execution::Call(
12757 isolate, eval_fun, receiver, 0, NULL, &pending_exception); 12756 isolate, eval_fun, receiver, 0, NULL, &pending_exception);
12758 12757
12759 if (pending_exception) return Failure::Exception(); 12758 if (pending_exception) return Failure::Exception();
12760 12759
(...skipping 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after
14588 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ 14587 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
14589 return isolate->heap()->ToBoolean(obj->Has##Name()); \ 14588 return isolate->heap()->ToBoolean(obj->Has##Name()); \
14590 } 14589 }
14591 14590
14592 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) 14591 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements)
14593 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) 14592 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements)
14594 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements) 14593 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements)
14595 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) 14594 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements)
14596 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastHoleyElements) 14595 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastHoleyElements)
14597 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) 14596 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements)
14598 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(NonStrictArgumentsElements) 14597 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SloppyArgumentsElements)
14599 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) 14598 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements)
14600 // Properties test sitting with elements tests - not fooling anyone. 14599 // Properties test sitting with elements tests - not fooling anyone.
14601 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) 14600 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties)
14602 14601
14603 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION 14602 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION
14604 14603
14605 14604
14606 #define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \ 14605 #define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \
14607 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \ 14606 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \
14608 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ 14607 CONVERT_ARG_CHECKED(JSObject, obj, 0); \
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
14961 // Handle last resort GC and make sure to allow future allocations 14960 // Handle last resort GC and make sure to allow future allocations
14962 // to grow the heap without causing GCs (if possible). 14961 // to grow the heap without causing GCs (if possible).
14963 isolate->counters()->gc_last_resort_from_js()->Increment(); 14962 isolate->counters()->gc_last_resort_from_js()->Increment();
14964 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14963 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14965 "Runtime::PerformGC"); 14964 "Runtime::PerformGC");
14966 } 14965 }
14967 } 14966 }
14968 14967
14969 14968
14970 } } // namespace v8::internal 14969 } } // namespace v8::internal
OLDNEW
« src/preparser.h ('K') | « src/runtime.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698